Measuring Database Restore Times

A friend of mine asked me if there was a good way for measuring how long a given [http://www.postgresql.org/docs/current/interactive/app-pgrestore.html restore] takes. PostgreSQL doesn’t have a way to do this itself, so generally you need to rely on the operating system for this information. The way he was doing it was by wrapping his restores with date commands, like this:
-bash-3.00$ date; pg_restore -d pagila -Fc pagila.pgr; date; Thu Jul 6 09:58:50 EDT 2006 Thu Jul 6 09:58:54 EDT 2006
Which works well enough, giving you a start and stop time with which you can do some math on to get the restore time. Another method I use is to prefix the restore with the unix time command, here is one I did from yesterday:
[root@rmstest ~]# time pg_restore -U postgres -a –disable-triggers -d rmswh -Fc rmswh.pgr real    704m38.519s user    62m45.416s sys     7m32.382s
Hopefully this will help others out there. Please post if you have another method you’re partial to… Or if you know a way to do this on Windows; I’m sure there must be one, but I don’t know of it.