Giles Bowkett
2008-Jan-04 15:55 UTC
[rspec-users] best way to modify spec (the command-line tool)?
Hi all, where I work we''ve cooked up a kind of ghetto profiler for our specs. It basically just does this: time = Time.now # run the spec puts "woah! dude. long spec." if time > 1.second I''m simplifying here. I think the threshold is actually 0.1 seconds, and we use more precise language, and highlight the spec in red via terminal colors, etc. But the way it works is a bit ghetto. We just manually hacked it onto the Rails example groups (it''s a Rails project) and then added a shell env var to turn it on and off. What''s the cleanest way to implement this? Add a -profiling command-line flag to spec itself? Is there a single point of entry and exit for running individual specs that I can put the code around? It''s currently manually hacked onto each example group individually and it seems a bit untidy. -- Giles Bowkett Podcast: http://hollywoodgrit.blogspot.com Blog: http://gilesbowkett.blogspot.com Portfolio: http://www.gilesgoatboy.org Tumblelog: http://giles.tumblr.com
David Chelimsky
2008-Jan-04 16:08 UTC
[rspec-users] best way to modify spec (the command-line tool)?
On Jan 4, 2008 9:55 AM, Giles Bowkett <gilesb at gmail.com> wrote:> Hi all, where I work we''ve cooked up a kind of ghetto profiler for our > specs. It basically just does this: > > time = Time.now > # run the spec > puts "woah! dude. long spec." if time > 1.second > > I''m simplifying here. I think the threshold is actually 0.1 seconds, > and we use more precise language, and highlight the spec in red via > terminal colors, etc. > > But the way it works is a bit ghetto. We just manually hacked it onto > the Rails example groups (it''s a Rails project) and then added a shell > env var to turn it on and off. > > What''s the cleanest way to implement this?Hey Giles, we''ve already done this for you! spec some_directory --format profile This will print out the 10 slowest examples (regardless of threshold). Cheers, and welcome to the RSpec community! David> Add a -profiling > command-line flag to spec itself? Is there a single point of entry and > exit for running individual specs that I can put the code around? It''s > currently manually hacked onto each example group individually and it > seems a bit untidy. > > -- > Giles Bowkett > > Podcast: http://hollywoodgrit.blogspot.com > Blog: http://gilesbowkett.blogspot.com > Portfolio: http://www.gilesgoatboy.org > Tumblelog: http://giles.tumblr.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Ben Mabey
2008-Jan-04 16:14 UTC
[rspec-users] best way to modify spec (the command-line tool)?
On rspec''s specs I have noticed they have a profiling flag that they pass into the spec command. What is does is print out the longest specs with there times. So you may not have to rewrite this.. I have tried using the flag on my own projects but it didn''t work. Maybe someone from the dev team could enlighten us on how to use that nifty trick? -Ben Giles Bowkett wrote:> Hi all, where I work we''ve cooked up a kind of ghetto profiler for our > specs. It basically just does this: > > time = Time.now > # run the spec > puts "woah! dude. long spec." if time > 1.second > > I''m simplifying here. I think the threshold is actually 0.1 seconds, > and we use more precise language, and highlight the spec in red via > terminal colors, etc. > > But the way it works is a bit ghetto. We just manually hacked it onto > the Rails example groups (it''s a Rails project) and then added a shell > env var to turn it on and off. > > What''s the cleanest way to implement this? Add a -profiling > command-line flag to spec itself? Is there a single point of entry and > exit for running individual specs that I can put the code around? It''s > currently manually hacked onto each example group individually and it > seems a bit untidy. > >
George Anderson
2008-Jan-04 16:31 UTC
[rspec-users] best way to modify spec (the command-line tool)?
"ghetto profiler": how appropriate for rails work these days. You might ask on the rspec-devel list if you haven''t already. http://rubyforge.org/mail/?group_id=797 While you''re waiting for a response, consider watching Zed''s interpretive piece in which he channels the King: http://www.youtube.com/watch?v=zmVFnhO3A98 /g On 1/4/08, Giles Bowkett <gilesb at gmail.com> wrote:> Hi all, where I work we''ve cooked up a kind of ghetto profiler for our > specs. It basically just does this: > > time = Time.now > # run the spec > puts "woah! dude. long spec." if time > 1.second > > I''m simplifying here. I think the threshold is actually 0.1 seconds, > and we use more precise language, and highlight the spec in red via > terminal colors, etc. > > But the way it works is a bit ghetto. We just manually hacked it onto > the Rails example groups (it''s a Rails project) and then added a shell > env var to turn it on and off. > > What''s the cleanest way to implement this? Add a -profiling > command-line flag to spec itself? Is there a single point of entry and > exit for running individual specs that I can put the code around? It''s > currently manually hacked onto each example group individually and it > seems a bit untidy. > > -- > Giles Bowkett > > Podcast: http://hollywoodgrit.blogspot.com > Blog: http://gilesbowkett.blogspot.com > Portfolio: http://www.gilesgoatboy.org > Tumblelog: http://giles.tumblr.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-- George Anderson BenevolentCode LLC O: (410) 461-7553 C: (410) 218-5185 george at benevolentcode.com
David Chelimsky
2008-Jan-04 16:37 UTC
[rspec-users] best way to modify spec (the command-line tool)?
On Jan 4, 2008 10:14 AM, Ben Mabey <ben at benmabey.com> wrote:> On rspec''s specs I have noticed they have a profiling flag that they > pass into the spec command. What is does is print out the longest specs > with there times. So you may not have to rewrite this.. I have tried > using the flag on my own projects but it didn''t work. Maybe someone > from the dev team could enlighten us on how to use that nifty trick?It should just work with --format profile. What are you experiencing when you do that?> > -Ben > > > Giles Bowkett wrote: > > Hi all, where I work we''ve cooked up a kind of ghetto profiler for our > > specs. It basically just does this: > > > > time = Time.now > > # run the spec > > puts "woah! dude. long spec." if time > 1.second > > > > I''m simplifying here. I think the threshold is actually 0.1 seconds, > > and we use more precise language, and highlight the spec in red via > > terminal colors, etc. > > > > But the way it works is a bit ghetto. We just manually hacked it onto > > the Rails example groups (it''s a Rails project) and then added a shell > > env var to turn it on and off. > > > > What''s the cleanest way to implement this? Add a -profiling > > command-line flag to spec itself? Is there a single point of entry and > > exit for running individual specs that I can put the code around? It''s > > currently manually hacked onto each example group individually and it > > seems a bit untidy. > > > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Ben Mabey
2008-Jan-04 16:55 UTC
[rspec-users] best way to modify spec (the command-line tool)?
David Chelimsky wrote:> On Jan 4, 2008 10:14 AM, Ben Mabey <ben at benmabey.com> wrote: > >> On rspec''s specs I have noticed they have a profiling flag that they >> pass into the spec command. What is does is print out the longest specs >> with there times. So you may not have to rewrite this.. I have tried >> using the flag on my own projects but it didn''t work. Maybe someone >> from the dev team could enlighten us on how to use that nifty trick? >> > > It should just work with --format profile. What are you experiencing > when you do that? > >I just tried that and it worked great, thanks. Before, I didn''t realize it was a formatter and thought it was its own flag. Thanks! -Ben>> -Ben >> >> >> Giles Bowkett wrote: >> >>> Hi all, where I work we''ve cooked up a kind of ghetto profiler for our >>> specs. It basically just does this: >>> >>> time = Time.now >>> # run the spec >>> puts "woah! dude. long spec." if time > 1.second >>> >>> I''m simplifying here. I think the threshold is actually 0.1 seconds, >>> and we use more precise language, and highlight the spec in red via >>> terminal colors, etc. >>> >>> But the way it works is a bit ghetto. We just manually hacked it onto >>> the Rails example groups (it''s a Rails project) and then added a shell >>> env var to turn it on and off. >>> >>> What''s the cleanest way to implement this? Add a -profiling >>> command-line flag to spec itself? Is there a single point of entry and >>> exit for running individual specs that I can put the code around? It''s >>> currently manually hacked onto each example group individually and it >>> seems a bit untidy. >>> >>> >>> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
David Chelimsky
2008-Jan-04 17:06 UTC
[rspec-users] best way to modify spec (the command-line tool)?
On Jan 4, 2008 10:55 AM, Ben Mabey <ben at benmabey.com> wrote:> David Chelimsky wrote: > > On Jan 4, 2008 10:14 AM, Ben Mabey <ben at benmabey.com> wrote: > > > >> On rspec''s specs I have noticed they have a profiling flag that they > >> pass into the spec command. What is does is print out the longest specs > >> with there times. So you may not have to rewrite this.. I have tried > >> using the flag on my own projects but it didn''t work. Maybe someone > >> from the dev team could enlighten us on how to use that nifty trick? > >> > > > > It should just work with --format profile. What are you experiencing > > when you do that? > > > > > > I just tried that and it worked great, thanks. Before, I didn''t realize > it was a formatter and thought it was its own flag. Thanks!n/p Glad you got it working. Cheers, David
Giles Bowkett
2008-Jan-04 19:41 UTC
[rspec-users] best way to modify spec (the command-line tool)?
> Hey Giles, we''ve already done this for you! > > spec some_directory --format profile > > This will print out the 10 slowest examples (regardless of threshold). > > Cheers, and welcome to the RSpec community!Doh! Gracias. :-) -- Giles Bowkett Podcast: http://hollywoodgrit.blogspot.com Blog: http://gilesbowkett.blogspot.com Portfolio: http://www.gilesgoatboy.org Tumblelog: http://giles.tumblr.com