New Railsbench Release (0.9.2)

Posted about 7 years back at RailsExpress.blog

A new version of railsbench has been released. Benchmarking POST requests is now supported, benchmark specific session data can be specified in the benchmark config file and ERB can be used as well.

  • added POST support:
        search:
          uri: /search
          method: post
          post_data: category=dessert
    
    • method defaults to get
    • post_data will be url encoded by railsbench
  •  
  • allow specification of session_data in benchmarks.yml:
        benchmark_name:
          uri: /
          session_data:
             user_id: 1
          post_data: category=dessert
    
  •  
  • load benchmarks.yml using ERB. Example: retrieve login ids using Rails)
        admin_interface:
          uri: /admin
          session_data:
            user_id: <%= User.find_by_name('admin').id %>
    
  •  
  • use benchmark names instead of urls in raw data files, old files can be converted using script convert_raw_data_files. change was required by post support
  •  
  • copy environments/production.rb to environments/benchmarking.rb, instead of providing a fixed one
  •  
  • don’t create a broken benchmarks.yml file when running railsbench install
  •  
  • perf_plot and perf_plot_gc accept -geometry parameter, for exact dimensioning of the produced .png file
  •  
  • use -font_size=12 for setting font size when generating graphs
  •  
  • use ‘perf_plot -colors=color1,color2,...’ to get a different color set
  •  
  • use ‘perf_plot -out=name’ to write graph to file ‘name’
  •  
  • new script perf_table: create a tabular overview of perf data
  •  
  • added -colorize option to perf_html, which results in green and red backgrounds in the factor columns
  •  
  • added -theme option to perf_plot

Happy benchmarking!

Rails 1.2 Performance

Posted about 7 years back at RailsExpress.blog

Rails 1.2-stable is somewhat slower than Rails 1.1-stable, especially on action cached pages. But the slowdown I measured is nowhere near the numbers which have been reported by others. In fact, two recent patches to speed up session creation and pstore session retrieval, have resulted in improved performance for one of the benchmarked actions.

The following performance data table shows the speed difference for the fastest availabe configuration for the tested application.

<style type="text/css"> </style>
page c1 totalc2 total c1 r/sc2 r/s c1 ms/rc2 ms/r c1/c2
empty 11.4403410.91962 437.0457.9 2.292.18 1.05
welcome 13.0464814.29709 383.2349.7 2.612.86 0.91
recipes 10.8361713.51635 461.4369.9 2.172.70 0.80
my_recipes 10.8013713.48035 462.9370.9 2.162.70 0.80
show 24.1672227.37878 206.9182.6 4.835.48 0.88
cat 26.5603829.88683 188.3167.3 5.315.98 0.89
cat_page5 27.2495430.78081 183.5162.4 5.456.16 0.89
letter 26.9906730.17507 185.2165.7 5.406.04 0.89
all requests 151.09216170.43488 264.7234.7 3.784.26 0.89
GC statistics c1 totalc2 total c1 #gcc2 #gc c1 gc%c2 #gc% c1/c2
10.4279012.90426 120.0135.0 6.907.57 0.81

c1: 1.1-stable, c2: 1.2-stable, r/s: requests per second, ms/r: milliseconds per request

Read the full report here.

Episode 12: Refactoring User Name Part 3

Posted about 7 years back at Railscasts

In the final part of this series you will see how to refactor your tests. Keeping tests clean is important because it will make testing easier to do in the future.

Michael Buffington and Stikkit - Ruby on Rails Podcast

Posted about 7 years back at Ruby on Rails Podcast

The serial entrepreneur
talks about his latest startup.
Also mentioned:

New Contact Feedback Plugin

Posted about 7 years back at Mephisto - Home

James Crisp wrote a nifty Contact Feedback plugin for Mephisto for the new Thoughtworks Studios site. The plugin looks nice, and fills a common need in Mephisto. Also, the Thoughtworks Studios site is extremely well-done. I had seen it before, but didn’t realize it used Mephisto. Major kudos to James Crisp and Thoughtworks!

For anyone that asks: it looks like the main difference between this, and my own feedback plugin is that mine doesn’t send emails. It stores them in the DB and lets you browse in the admin. Nice since your inbox doesn’t get the spam, but I’ve been finding that I often forget to check it :)

Customising controllers - new API

Posted about 7 years back at The Hobo Blog

One of the nice things about Hobo is that you never have to write the seven boilerplate actions to get a basic CRUD controller (index, show, new, create, edit, update and destroy). The downside is that if you need to tweak the behaviour of one of those actions, there’s no code in your controller to tweak.

I’ve been addressing that issue by adding hook points, e.g. you can define create_response and invalid_create_response in order to override Hobo’s default responses. I’ve never been totally happy with that approach though - the number of such hooks is bound to grow until there’s a rather complex little API in there, which we certainly don’t want.

Today I’m having a go at a different approach. The index action in Hobo’s model controller is now as follows:

def index
  hobo_index
end

The hobo_index method (which is protected), can also be passed a bunch of parameters, so you could override index in your controller like this:

def index
  hobo_index :page_size => 10
end

Through parameters like that, you can customise pretty much everything. A common requirement is to include some eager loading in the ActiveRecord find:

def index
  hobo_index :items => Post.find(:all, :include => :comments)
end

Another trick - if you pass the items as a proc, the find will happen in a scope that handles pagination for you. (UPDATE: After some digging I’ve come across the idea, which I thoroughly agree with, that this is really an abuse of with_scope)

Baaad idea

def index
  hobo_index :items => proc { Post.find(:all, :include => :comments) }
end

So here’s the new way to achieve the same (and I renamed the :items parameter)

Good idea

def index
  hobo_index :collection => paginated_find(:include => :comments)
end

I think this approach is going to be easier to learn, while giving you a fine-grained choice between having Hobo do things for you, and having custom control.

Customising controllers - new API

Posted about 7 years back at The Hobo Blog

One of the nice things about Hobo is that you never have to write the seven boilerplate actions to get a basic CRUD controller (index, show, new, create, edit, update and destroy). The downside is that if you need to tweak the behaviour of one of those actions, there’s no code in your controller to tweak.

I’ve been addressing that issue by adding hook points, e.g. you can define create_response and invalid_create_response in order to override Hobo’s default responses. I’ve never been totally happy with that approach though - the number of such hooks is bound to grow until there’s a rather complex little API in there, which we certainly don’t want.

Today I’m having a go at a different approach. The index action in Hobo’s model controller is now as follows:

def index
  hobo_index
end

The hobo_index method (which is protected), can also be passed a bunch of parameters, so you could override index in your controller like this:

def index
  hobo_index :page_size => 10
end

Through parameters like that, you can customise pretty much everything. A common requirement is to include some eager loading in the ActiveRecord find:

def index
  hobo_index :items => Post.find(:all, :include => :comments)
end

Another trick - if you pass the items as a proc, the find will happen in a scope that handles pagination for you. (UPDATE: After some digging I’ve come across the idea, which I thoroughly agree with, that this is really an abuse of with_scope)

Baaad idea

def index
  hobo_index :items => proc { Post.find(:all, :include => :comments) }
end

So here’s the new way to achieve the same (and I renamed the :items parameter)

Good idea

def index
  hobo_index :collection => paginated_find(:include => :comments)
end

I think this approach is going to be easier to learn, while giving you a fine-grained choice between having Hobo do things for you, and having custom control.

General Genetic Algorithms for Ruby (gga4r) release 0.9

Posted about 7 years back at Spejman On Rails

General Genetic Algorithms for Ruby (gga4r) is a library for executing generic algorithms easily.

Only 3 steps are needed in order to work with gga4r:

  1. Choose a clase to evolve and define for her the fitness, combine and mutate methods.

  2. With an array of last defined class instances (initial population), create a GeneticAlgorithm object.

  3. Call GeneticAlgorithm's evolve method as many times as you want.


More info:

Kathy and Chris sitting in a tree...

Posted about 7 years back at Wood for the Trees

Really hot stuff this Kathy Sierra nonsense. Oh wait, a tasteless pun. Is everyone going to hate me now? Grow up!

I usually don’t wade into political debate because it is full of morons, but it’s the middle of the night and I’m really bored. In fact, annoyed. Like I was with Rails 1.2 (how’s that for continuity!)

Who I Sympathise With and Who I Support

I’ll give, frankly, my sympathy to Kathy (who is manic, slightly weak-willed, has some good ideas, some other ideas a little dodgy, and has all the traits of a modern American woman, for good or ill) but I give my serious support to those calling for uncommon sense. This situation is so cliched and yet has slipped passed a few people I respect that I’m going to kill some time here and point out that Dave Winer, who I never heard of before, is right to be skeptical. He made just one mistake: he wasn’t confident enough to spell out why others should be. Please, please stop fuelling the media. It’s just evil.

So, without further ado, the train of thought:

The gist of my view:

  • Threats and offensive comments on the internet are newsworthy, therefore not worth my time (unless I’m killing it).
  • Being a high-profile speaker in the IT world will have its share of ‘acerbic’ commentary
  • Being a blogger will get you the same
  • Putting your details online is just dumb
  • Men abuse each other using sexual language, but we’ve got used to it over the last five millenia and now think it’s kind of amusing

For example, the Bile Blog, which is an institution in slagging shit off. Thankfully it still exists. Poor Hani doesn’t get a BBC article because the Bile stays strictly asexual. But in a post-feminist, emasculated society, you can get really hated for saying anything remotely gender-specific. I’m sorry, but I don’t buy that. It’s proscriptive and - for the same reason I think I should be able to take a pie or bottle of water on a plane even at the risk of being blown up - molly-coddling. Anyone with some self-respect and decency should feel a little spineless and self-indulgent if they coddle Kathy. A mild dose of feminist support is fine, because I like women to be people rather than objects, but indulging in the mass opinion is, well, like getting a labotomy. Some of the points Kathy made were, of course, right: it’s pretty sick some of those things she cited. However, it’s not rocket science to see she is also over-reacting and taking the majestic ‘blogosphere’ with her. Her avid fans who want to hang her are most likely infantile, possibly autistic twits in the middle of nowhere, with the social graces of a louse.

What’s the truth?

The situation is as plain as a Bulgarian pin-up. Kathy takes the net seriously and flips out. Her readers, which are many, believe her. Others who see those believe her think the readers must be right because there are so many of them. A few people are skeptical and they are lampooned, making the case even stronger that Kathy is being persecuted. It goes to the media, which means it must be true!

Qualifications

Please realise that there are minorities of both idiots and intelligent people in the real world just as much as on the internet, with one slight difference: ‘law’ isn’t firmly established online. That’s quite literally fantastical, but true, and we should cherish that infinite freedom. I don’t want a jackboot in my face for telling someone online they can stick their ideas up their cuntflap or hang by their genitals, nor see a person cuffed and imprisoned for behaving as amorally as Sodom. Your morals and theirs may not mix, but that’s neither here nor there. Morality is for religion, not law and the internet is lawless.

All this lovely lawlessness is because of its anonymity. People use that anonymity out of cowardice (yes) but also safety. Uh huh, that’s right. The louse should be protected too, all the way up until he actually clubs Kathy over the head and brings her back to his cave. That’s real free speech. It’s not pleasant sometimes, but it’s very, very important to realise how extreme an idea it is (the original one, not the hashed up piece of shit served by ‘democracies’ around the world).

Summary

Kathy thinks threats are equal to actions, for which she loses my support, though I still hope she pulls out of her mire of self-doubt and back into posting for her readers. Maybe during that period she should read some comforting Spinozan ideas on epistemology and semantics.

Resorting to qualified (that is, reasoned) support and sympathy is quite different from just jumping on the wagon of lynchers, to use Chris Locke’s own words.

Just as a reminder, this is where enforcing morality leads. BBC are really getting lazy; they’ve got two articles on mass hysteria. But they are the news and cater to the lowest common denominator. It’s quite different when respected, intelligent individuals are the cause of the stir. I only hope some of you will give it a little more consideration next time and do the intelligent thing: be as long-winded as I am. Then no journalist could bear reading it.

Kathy and Chris sitting in a tree...

Posted about 7 years back at Wood for the Trees

Really hot stuff this Kathy Sierra nonsense. Oh wait, a tasteless pun. Is everyone going to hate me now? Grow up!

I usually don’t wade into political debate because it is full of morons, but it’s the middle of the night and I’m really bored. In fact, annoyed. Like I was with Rails 1.2 (how’s that for continuity!)

Who I Sympathise With and Who I Support

I’ll give, frankly, my sympathy to Kathy (who is manic, slightly weak-willed, has some good ideas, some other ideas a little dodgy, and has all the traits of a modern American woman, for good or ill) but I give my serious support to those calling for uncommon sense. This situation is so cliched and yet has slipped passed a few people I respect that I’m going to kill some time here and point out that Dave Winer, who I never heard of before, is right to be skeptical. He made just one mistake: he wasn’t confident enough to spell out why others should be. Please, please stop fuelling the media. It’s just evil.

So, without further ado, the train of thought:

The gist of my view:

  • Threats and offensive comments on the internet are newsworthy, therefore not worth my time (unless I’m killing it).
  • Being a high-profile speaker in the IT world will have its share of ‘acerbic’ commentary
  • Being a blogger will get you the same
  • Putting your details online is just dumb
  • Men abuse each other using sexual language, but we’ve got used to it over the last five millenia and now think it’s kind of amusing

For example, the Bile Blog, which is an institution in slagging shit off. Thankfully it still exists. Poor Hani doesn’t get a BBC article because the Bile stays strictly asexual. But in a post-feminist, emasculated society, you can get really hated for saying anything remotely gender-specific. I’m sorry, but I don’t buy that. It’s proscriptive and - for the same reason I think I should be able to take a pie or bottle of water on a plane even at the risk of being blown up - molly-coddling. Anyone with some self-respect and decency should feel a little spineless and self-indulgent if they coddle Kathy. A mild dose of feminist support is fine, because I like women to be people rather than objects, but indulging in the mass opinion is, well, like getting a labotomy. Some of the points Kathy made were, of course, right: it’s pretty sick some of those things she cited. However, it’s not rocket science to see she is also over-reacting and taking the majestic ‘blogosphere’ with her. Her avid fans who want to hang her are most likely infantile, possibly autistic twits in the middle of nowhere, with the social graces of a louse.

What’s the truth?

The situation is as plain as a Bulgarian pin-up. Kathy takes the net seriously and flips out. Her readers, which are many, believe her. Others who see those believe her think the readers must be right because there are so many of them. A few people are skeptical and they are lampooned, making the case even stronger that Kathy is being persecuted. It goes to the media, which means it must be true!

Qualifications

Please realise that there are minorities of both idiots and intelligent people in the real world just as much as on the internet, with one slight difference: ‘law’ isn’t firmly established online. That’s quite literally fantastical, but true, and we should cherish that infinite freedom. I don’t want a jackboot in my face for telling someone online they can stick their ideas up their cuntflap or hang by their genitals, nor see a person cuffed and imprisoned for behaving as amorally as Sodom. Your morals and theirs may not mix, but that’s neither here nor there. Morality is for religion, not law and the internet is lawless.

All this lovely lawlessness is because of its anonymity. People use that anonymity out of cowardice (yes) but also safety. Uh huh, that’s right. The louse should be protected too, all the way up until he actually clubs Kathy over the head and brings her back to his cave. That’s real free speech. It’s not pleasant sometimes, but it’s very, very important to realise how extreme an idea it is (the original one, not the hashed up piece of shit served by ‘democracies’ around the world).

Summary

Kathy thinks threats are equal to actions, for which she loses my support, though I still hope she pulls out of her mire of self-doubt and back into posting for her readers. Maybe during that period she should read some comforting Spinozan ideas on epistemology and semantics.

Resorting to qualified (that is, reasoned) support and sympathy is quite different from just jumping on the wagon of lynchers, to use Chris Locke’s own words.

Just as a reminder, this is where enforcing morality leads. BBC are really getting lazy; they’ve got two articles on mass hysteria. But they are the news and cater to the lowest common denominator. It’s quite different when respected, intelligent individuals are the cause of the stir. I only hope some of you will give it a little more consideration next time and do the intelligent thing: be as long-winded as I am. Then no journalist could bear reading it.

Sometimes It's The Little Things...

Posted about 7 years back at zerosum dirt(nap) - Home

With this latest RoR project, we decided for the first time to take a RESTful approach. It’s taken me much longer than it should have to come to terms with what that actually meant, but after suffering through the change of mindset, I really do have to say that it feels right. I’m down, you’ve won me over.

That said, there are always little implementation details that annoy the hell out of you. Little, trivial, stupid things. Things that you know you shouldn’t waste precious breath complaining about, things that you annoy your friends about until they ignore you. Things like the use of the damn semi-colon to delimit custom actions for resources in a URI, instead of our old friend the slash.

And then came Changeset 6485, which made everything once again right with the world. Thank gawd that’s over. Now I can get back to being productive :-).

Episode 11: Refactoring User Name Part 2

Posted about 7 years back at Railscasts

Testing and refactoring go hand in hand. Refactoring is all about improving code without changing its behavior. Testing is all about making sure you don't change the behavior while you are improving the code.

Second screencast posted in Flash

Posted about 7 years back at The Hobo Blog

A few folk seem to be having trouble with the audio in the second screencast. We’ve just posted a rough Flash version as a stop-gap solution. The quality is a bit naff but it’s better than not being able to hear anything!

If anyone can recommend a nice tool for converting QuickTime to a good quality backwards-compatible Flash movie, please let us know in the comments. Thanks!

Second screencast posted in Flash

Posted about 7 years back at The Hobo Blog

A few folk seem to be having trouble with the audio in the second screencast. We’ve just posted a rough Flash version as a stop-gap solution. The quality is a bit naff but it’s better than not being able to hear anything!

If anyone can recommend a nice tool for converting QuickTime to a good quality backwards-compatible Flash movie, please let us know in the comments. Thanks!

Episode 10: Refactoring User Name Part 1

Posted about 7 years back at Railscasts

Learn how to clean up your code through refactoring. This episode will show you how to move code from the view into the model to remove duplication and simplify the view.