Skip to content
  • Chris Griego's avatar
    a962bfe4
    Optimize ActiveResource::Base.new(attributes) · a962bfe4
    Chris Griego authored
    * Add performance benchmark similar to ActiveRecord
    * Lazily find_or_create_resource_for_collection to not incur the overhead for empty arrays and arrays of primatives
    * #duplicable? is faster than inline rescues when the object is not duplicable
    * Don't constantly raise and handle NameError, raising is expensive
    * Even when a resource is nested inside a module, always look inside the class first for the resource definition so we don't overwrite classes all the time
    
    Before:                                     user     system      total        real
    Model.new (instantiation)               0.120000   0.000000   0.120000 (  0.119961)
    Nested::Model.new (instantiation)       0.150000   0.010000   0.160000 (  0.151183)
    Model.new (setting attributes)         28.540000   0.680000  29.220000 ( 29.271775)
    Nested::Model.new (setting attributes) 29.740000   0.580000  30.320000 ( 30.486210)
    
    After:                                        user     system      total        real
    Model.new (instantiation)                 0.120000   0.000000   0.120000 (  0.121249)
    Nested::Model.new (instantiation)         0.150000   0.010000   0.160000 (  0.152429)
    Model.new (setting attributes)           11.480000   0.170000  11.650000 ( 11.656163)
    Nested::Model.new (setting attributes)   11.510000   0.210000  11.720000 ( 11.724249)
    a962bfe4
    Optimize ActiveResource::Base.new(attributes)
    Chris Griego authored
    * Add performance benchmark similar to ActiveRecord
    * Lazily find_or_create_resource_for_collection to not incur the overhead for empty arrays and arrays of primatives
    * #duplicable? is faster than inline rescues when the object is not duplicable
    * Don't constantly raise and handle NameError, raising is expensive
    * Even when a resource is nested inside a module, always look inside the class first for the resource definition so we don't overwrite classes all the time
    
    Before:                                     user     system      total        real
    Model.new (instantiation)               0.120000   0.000000   0.120000 (  0.119961)
    Nested::Model.new (instantiation)       0.150000   0.010000   0.160000 (  0.151183)
    Model.new (setting attributes)         28.540000   0.680000  29.220000 ( 29.271775)
    Nested::Model.new (setting attributes) 29.740000   0.580000  30.320000 ( 30.486210)
    
    After:                                        user     system      total        real
    Model.new (instantiation)                 0.120000   0.000000   0.120000 (  0.121249)
    Nested::Model.new (instantiation)         0.150000   0.010000   0.160000 (  0.152429)
    Model.new (setting attributes)           11.480000   0.170000  11.650000 ( 11.656163)
    Nested::Model.new (setting attributes)   11.510000   0.210000  11.720000 ( 11.724249)
Loading