On Apr 9, 11:53 am, Jeremy Evans <[email protected]> wrote:
> Well, it can't return self, but it can return a direct clone.  Try the
> patch athttp://pastie.org/911966.txtand let me know if it has the
> functionality you had in mind.

Unfortunately, there's a 15% performance decrease for Dataset#filter
using that patch, so I can't accept it:

With:

irb(main):019:0> puts
Benchmark.measure{100000.times{ds.filter(:a=>1)}}
  3.600000   0.450000   4.050000 (  4.058307)
=> nil
irb(main):020:0> puts
Benchmark.measure{100000.times{ds.filter(:a=>1)}}
  3.690000   0.340000   4.030000 (  4.028950)
=> nil
irb(main):021:0> puts
Benchmark.measure{100000.times{ds.filter(:a=>1)}}
  3.620000   0.440000   4.060000 (  4.054360)

Without:

irb(main):003:0> puts
Benchmark.measure{100000.times{ds.filter(:a=>1)}}
  3.210000   0.270000   3.480000 (  3.481032)
=> nil
irb(main):004:0> puts
Benchmark.measure{100000.times{ds.filter(:a=>1)}}
  3.190000   0.260000   3.450000 (  3.454075)
=> nil
irb(main):005:0> puts
Benchmark.measure{100000.times{ds.filter(:a=>1)}}
  3.070000   0.400000   3.470000 (  3.477142)

Thankfully, most of that 15% seems to be overhead of creating objects
unnecessary in every call, which is easy to eliminate (see
http://pastie.org/912025.txt):

irb(main):003:0> puts
Benchmark.measure{100000.times{ds.filter(:a=>1)}}
  3.370000   0.200000   3.570000 (  3.567935)
=> nil
irb(main):004:0> puts
Benchmark.measure{100000.times{ds.filter(:a=>1)}}
  3.280000   0.260000   3.540000 (  3.544439)
=> nil
irb(main):005:0> puts
Benchmark.measure{100000.times{ds.filter(:a=>1)}}
  3.220000   0.350000   3.570000 (  3.573647)

This brings the performance decrease to about 2.5%, which is still
more than I'd like, but I'll at least consider it.

Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to