The existing answers are better for how to get the correct value, but I can at least explain why getrusage isn't working for you.
man 2 getrusage:
The above struct [rusage] was taken from BSD 4.3 Reno. Not all fields are meaningful under Linux. Right now (Linux 2.4, 2.6) only the fields ru_utime, ru_stime, ru_minflt, ru_majflt, and ru_nswap are maintained.