Archive for July, 2008

Profile your Rails RSpec and find your slow tests fast

Long-as-hell Ruby on Rails RSpec test running times are making you ask “what the deuce?” Specs are taking way too long to run, but the prospect of looking through them all one at a time to find offending external dependencies, net calls that should be mocked, etc is driving you to drink. You just want a read-out of the tests that are taking the longest so you can refactor ASAP.

Sound familiar?

I was in this boat until I found out about the profiling command:

1
$>spec spec -f profile

The double “spec” here can be a bit confusing. The first is the command, and the second is the directory (RAILS_ROOT/spec) that you’re running it on. The -f is the format flag. You can see a list of all formats with:

1
$>spec --help

Basically you’re just passing the “profile” argument to the formatting command. It gives you a readout of the 10 most time-intensive specs at the top and then a nicely verbose list of all pending and failed tests. Using this list, I was able to go straight to the most obnoxious offenders and eliminate the external dependencies (these specs happened to be fetching feeds) that were slowing my test suite down. In less than 15 minutes, I had chopped my execution time down to 10% of what it was before I started.

Huzzah!

“BIGGER AND RUSSIANER”

Where can you see a shirtless barbarian version of Gorbachev beat the shit out of Stalin zombies with axe, gun, and lasers from his eyes? The same place you can see the buxom women he saves morph from demure commie laborers into bikini-clad, capitalist super-babes dancing in a rain of Coca Cola bottles and Twinkies…

Hard to laugh at BO

Apparently, it’s hard to make fun of Barack Obama:

Why? The reason cited by most of those involved in the shows is that a fundamental factor is so far missing in Mr. Obama: There is no comedic “take” on him, nothing easy to turn to for an easy laugh, like allegations of Bill Clinton’s womanizing, or President Bush’s goofy bumbling or Al Gore’s robotic persona.

“The thing is, he’s not buffoonish in any way,” said Mike Barry, who started writing political jokes for Johnny Carson’s monologues in the waning days of the Johnson administration and has lambasted every presidential candidate since, most recently for Mr. Letterman. “He’s not a comical figure,” Mr. Barry said.

Jokes have been made about what Senator Hillary Rodham Clinton really thought about Mr. Obama during the primaries, and about the vulgar comments the Rev. Jesse Jackson made about him last week. But anything approaching a joke about Mr. Obama himself has fallen flat.

I gotta say, I take a certain amount of comfort in the idea of a Democratic candidate for President who it’s hard to mock…

Tags: ,

Autotester and GrowlGlue – an adventurer is me!

Setting up autotest earlier today was kind of an annoying, semi-humbling experience. A few things that people should know to save themselves some trouble:

  • Everyone calls it autotest, but it’s actually ZenTest that you need to install. ZenTest is a larger testing package, of which autotest is merely one part.
  • Autotest runs as a separate process (which you should background — the ‘&’ is your friend!) and watches your Rails dir after you have it turned on. This last bit took me some time to figure out, as the otherwise excellent RSpec Peepcode screencast completely glosses over this point. I kept waiting for the magic to happen when I hit “save” in TextMate, but I didn’t have the process running from the command line. Magic doesn’t work. I should stop expecting it to.
  • Do yourself a favor and vastly simplify your autotest–>Growl connection by using Collin VanDyck’s GrowlGlue gem as the basis for your .autotest config file.

As of right now, I’m sitting here with just the basic GG config. I’m sure I’ll expand/customize tomorrow, but I’m just happy for now that I was able to get a working setup with just one line of code, as the normal way to get the connection going involves a decent amount of crap. After you get that going, GrowlGlue lets you set up all sorts of customization of the notifications — including custom messages, custom notification icons, and even speaking your test results through OS X’s built-in text-to-speech support — in nice, neat Ruby statements.

It’s nice to have something get in my face about my tests, and it’s also nice to have something that automatically makes you want to get your tests passing and running faster. Autotest provides you with the nagging voice that says “get your tests running right, holmes!” It’s good to strike this longstanding to-do off my list.

Late update: Turns out that running autotest in the background isn’t really ideal since you might sometimes want to cancel a running suite or check out the time elapsed since you started a given test set. What I’m looking for now is a way to see how long it takes any individual test to run so that I can find the offenders that are kicking up the aggregate time.

Tags: , ,

Getting GTD Done – iGTD ditched for OmniFocus

I recently began using OmniFocus for GTD. I’d been using iGTD for the past year or so, and had been resonably happy with it. It allowed projects and contexts, easy setting of start/due dates, and had a 1-5 level of priority you could set. Not really appropriate for the hardest core of GTD faithful, but nice if you just wanted a fast way to keep track of everything you need to do.

But eventually, I realized that in iGTD, I was getting what I paid for. The syncing w/ .Mac was spotty at best, and after having my stuff zapped twice, I decided that I needed to move to something else. The logical choice, especially in light of the fact that they were releasing an iPhone version was OmniFocus.

Moving from iGTD to OmniFocus was like moving from a Ford Tempo to Mercedes M-Class. When you first get into it, there’s a lot of “what they hell does that do?” and “do I really need that?” Through the excellent included tutorials and the introductory video on OmniGroup’s site, the answer to the first question was never very far away. The answer to the second question has so far been “hell yes” — just as soon as I figure out why.

Cool stuff:

  • Perspectives – OmniFocus has a rich interface for creating views of exactly what you want to see at any given time. Projects organized by date due. Tasks organized by what’s next, in order of the amount of time you’ve said it will take to complete each one. A view of nothing but what you have to do today. All of these things are possible, but ordering them is kind of a pain. Perspectives let you preset those and come back to them over and over. It even gives you the option of opening them in a new window so they don’t have to disturb the view you’re looking at currently.
  • “Waiting” context – This is something you can apply to any given context — making it a place for tasks that are pending some other action. I’ll probably create one of these for my work stuff so that I can note the times when something is on hold pending someone else’s actions. In iGTD, this was on a task-by-task basis. In OF, it’s a property of a context.
  • Modal planning/doing – It’s taken me a bit to get used to this, but now I’m liking it: OF basically assumes two different primary modes of use — one for planning things out and one for moving through things. The planning, or Outline view shows you a list of projects. The Context view shows you, well, contexts. The assumption is that you’re going to be thinking in terms of projects when you’re planning/adding things to your lists and that you’ll be thinking in terms of contexts when you’re trying to actually do work. Perspectives follow this, allowing each to be associated with one view or the other. iGTD only had one view for everything.
  • Voice notes – I’m putting this here on faith, as I haven’t used it yet. There’s a shyness factor to get over for some reason whenever I’m confronted with a voice-based input — I’m not too keen on the idea of talking notes to my computer in my office, which I share with a co-worker, and doing it at home would probably get me mocked by my spouse. But I can see how this would be a useful alternative to typing notes.

There are more cool things about the app, but I’m still in the discovery phase. There are also some things about it that kind of piss me off:

  • Price – I thought that $70 was a little too much money for this. I was also pretty peeved that I couldn’t get the iPhone app for free or significantly discounted. I know they’re designed as free-standing apps that can be used independently of each other, but c’mon — how many users are actually going to go that route? The iPhone app is going to be, in practice, an extension of the desktop app. It should be priced as such.
  • U/I troubles – In the planning view, I frequently make a project when I’m trying to make a new task in a given project. I don’t like that I can’t double click to get a new task (you have to press the return key). Mouse-based manipulation of tasks is maddening — the only place you can click to drag is a small bullet on the left end of the task — single-clicking anywhere else has you actually editing the task. In iGTD, you had to double-click any given field to edit it, which made more sense to me.
  • iPhone task editing seems buggy – I can’t find much evidence of other people having the problem, but it appears that when the iPhone is attempting to find new items on the server (which can take for freaking ever), any new task you add to the phone is simply not saved. This is when the bottom spinner icon is doing its seemingly never-ending dance. Sync shouldn’t be an automatic thing. But the app is brand-new, and the syncing stuff is in the v1.1 of the desktop app, which is pre-release software, so I’ll give them the benefit on this one.

Like I said — I’m still learning. The tentative verdict so far is that I love the new system, but as effusive as that kind of praise is, it doesn’t take much to sour one on a GTD experience. One bad feature or persistent problem issue will cause you to drop the thing, as I did w/ iGTD. If the iPhone stuff doesn’t get better pretty fast, I’m going to be pissed, considering I had to shell out $90 for the combined desktop and iPhone apps.

Tags: