This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [v3][PATCH] Framework for performance benchmarking of functions


On 2013-02-20 02:17, Siddhesh Poyarekar wrote:
+  for (i = 0; i < ITER; i++)
+    {
+      for (j = 0; j < NUM_SAMPLES; j++)
+	{
+	  clock_gettime (CLOCK_MONOTONIC_RAW, &start);
+	  BENCH_FUNC(j);
+	  clock_gettime (CLOCK_MONOTONIC_RAW, &end);
+
+	  int64_t cur = (end.tv_nsec - start.tv_nsec
+			 + (end.tv_sec - start.tv_sec) * 1000000000);

The 1e9 constant needs to be cast to int64_t, lest this expression simply overflow on 32-bit hosts.


There are quite a few hosts for which the resolution of this clock isn't good enough to make measuring in the inside loop work. Can we have a look at what clock_getres returns and perhaps measure the outside loop? At least then we'll get *some* sort of answer...

E.g. ARM Cortex A9 can only measure at 1kHz, but Cortex A15-mp can measure at the cpu frequency (1.6GHz, reported by getres as 1ns).


r~



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]