Personally, I think this is one of those the-library-is-doing-too-much for me scenario. As you pointed out, the relatively simple way to do it is the Ruby-way, not just the Sequel-way and its the way I do it naturally. I never would've assumed the library was intelligent about me passing empty filters in. What was Xterra's slogan? "Everything you need; nothing you don't"?
That's what I tend to think about Sequel. :-) Michael On Fri, Apr 9, 2010 at 3:21 PM, Jeremy Evans <[email protected]> wrote: > 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]<sequel-talk%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/sequel-talk?hl=en. > > -- http://codeconnoisseur.org -- 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.
