Code as artwork

Many people think of code as artwork in some way or another and consider good code something of elegance and beauty. While working today, I came across another example of that in a visual representation of a project I’m working on.

This image shows the call graph of the file I’m editing, which is one component of a much larger project. I made it with Python’s hotshot profiler and José Fonseca’s Gprof2dot. Brighter colors mean more time is spent in those functions or their children, although it’s hard to see at this size. Or does it show some sort of futuristic gun? Your call.

The above callgraph shows every single function, but here’s a profile generated with the same tools that shows only functions that use a certain percentage of time. You can actually see the colors:

The tool you wished exists actually does: iotop

You heard it here last, to use sog‘s catchphrase. Haven’t you always wanted to track down the runaway process that was sucking up all your disk I/O? Now you can, with iotop. It’s a simple Python script, not even a full-out application. iotop uses the I/O accounting in newer 2.6 kernels >=2.6.20 (check whether /proc/self/io exists to see whether you’ve got it enabled) and requires at least Python 2.5 for AF_NETLINK sockets. Here’s what it looks like (click for larger image):

iotop screenshot

It shows overall disk read and write in MB/s. Per-process, it shows disk read and write speeds as well as percentage of time spent swapping in and percentage of time spent while waiting on I/O. In other words, it rocks.

To install it on Gentoo:
emerge iotop

You might need to sync your tree because I just added it. It’s still got testing keywords, so if you’re running stable, do this:
echo =dev-lang/python-2.5* >> /etc/portage/package.keywords
echo sys-process/iotop >> /etc/portage/package.keywords

Hot new GNOME apps in Gentoo

The inimitable Dave Neary just blogged about his favorite new GNOME apps, so I thought it’d be interesting to take a look at what it takes to get them running in Gentoo. To get a quick idea of the status, I searched our main tree and overlays using eix, then searched our Bugzilla using pybugz.

for i in gnome-do hamster tasque cheese vagalume pimlico transmission; do eix $i; bugz search $i; done

Here’s what I found (useless output removed):

* gnome-extra/gnome-do
Available versions: (~)0.4.2.0 {debug}
Homepage: http://do.davebsd.com/
Description: GNOME Do allows you to search for and perform actions on items in your desktop environment

* gnome-extra/gnome-do-plugins
Available versions: (~)0.4.0 {amarok debug evo}
Homepage: http://do.davebsd.com/
Description: Plugins to put the Do in Gnome Do

* gnome-extra/hamster-applet [1]
Available versions:  (~)0.6.1
Homepage:            http://projecthamster.wordpress.com/ http://code.google.com/p/projecthamster/
Description:         Time tracking for the masses, in a GNOME applet

[1] "sunrise" /usr/local/portage/layman/sunrise

[I] media-video/cheese
Available versions:  (~)2.22.0 (~)2.22.1 (~)2.22.2 {v4l}
Installed versions:  2.22.2(03:07:37 PM 06/18/2008)(v4l)
Homepage:            http://www.gnome.org/projects/cheese/
Description:         A cheesy program to take pictures and videos from your webcam

225775 maintainer-wanted    New ebuild: media-sound/vagalume-0.6 (Last.fm radi

* net-p2p/transmission
Available versions:  1.1.0 (~)1.11 (~)1.20 {gtk libnotify}
Homepage:            http://www.transmissionbt.com/
Description:         Simple BitTorrent client

Visiting the pimlico homepage, I found that it’s actually a suite of apps. Searching for their names revealed that we also have them. So far we’ve got gnome-do, hamster, cheese, vagalume, transmission and pimlico. Not too shabby. A quick Google search for the terms “tasque ebuild” found an ebuild for that, too! Apparently that overlay isn’t part of the eix cache, perhaps because it isn’t available through layman.

It’s worth noting that out of the 7 apps, 3 exist outside the main tree but are still trivial to find. I don’t have the time or interest in trying some of them myself. If you do try ’em, let folks know how it goes in the comments!

What can you learn from your own search and browsing history?

Google History lets you track and search your own browsing history as well as look at trends over time, on any browser with the Google Toolbar installed. (You can also do only searches without the toolbar, just signed into Google.) You can also get personalized search results based on what sites you’ve visited and what you’ve previously searched for. All of this requires that you in turn give Google access to where you’re going on the Web.

Since I signed up for the service a while ago, it’s certainly time to look at what I’m getting out of the deal. The easiest part to look at more quantitively is the trends. Here’s a calendar showing my search use over the month of May:

Calendar of May search history

What can we learn from this? The most obvious response is that I do a lot of searches, around 50-100 on a typical day. You can also pretty clearly see any day I’m not online, such as the vacation I took from May 22-25. I use Google a lot more than I thought–I certainly didn’t realize I was searching for things 100 times a day or more.

If we take a look at longer-term trends over the past year, things get pretty interesting:

Google search trends by month

Since June is where the wrap-around is from last year to this year, you might want to envision this chart instead starting at June and going to December, then January to May. My search use was pretty steady about a year ago, then it drastically dropped over the winter, then skyrocketed over the last few months. The winter drop correlates pretty well with final exams and a big push at work to get a paper written up and a grant submitted, both of which already had much of the online research done. I’m not sure how to explain the recent surge, though. I’ve been reading a lot more tech news, so it could be me looking up details about that. The same goes for interesting new software and websites I’ve looked into. I suspect the earlier 300-400 level is the most “normal,” so perhaps I’m just wasting more time over the past 3 months.

Another chart worth examining is the search activity by hour:

Search trends by hour

Looking at this and other data may make the monthly trends more clear too. I do the most searches shortly after getting to work, after lunch, and late at night, precisely the times I’m not getting as much work done. I would’ve guessed my most productive times at work are late morning before lunch and late afternoon, which seems to correlate well with the times with fewer searches. The nighttime increase is a whole different story, because that’s going to be work on Gentoo, which involves a lot more searching around the Web for solutions to problems.

How about searches by day of the week?

Search trends by day

If my conclusions from the hourly searches are accurate, I probably get the most done at work when I have the lowest search results, later in the week, and I’m guessing I generally don’t get as much done on Mondays. (Case of the Mondays, anyone?) The weekend drop is interesting too. Since I spend time working on Gentoo during weekends, I’m surprised the search total isn’t higher.

That’s about it for the trends. When looking at the websites I visited most often and terms I searched for most often, I knew they were actually fairly uncommon things. That indicated to me that I rarely search for the same thing or visit the same site over and over, so I’m not just using Google as an address bar for places I go often.

The main other thing that’s been useful for me is the ability to search my browsing history. Sometimes I remember the type of site I visited, but I don’t remember the name, and being able to search my history helps me find it. Usefully, Google also lets you sort results by date in case you can remember roughly when you were there.

Have you ever looked at your search or browsing trends? How did you do it? What did you conclude?