add freq_measure
authorJann Horn <jann@thejh.net>
Sun, 24 Nov 2013 02:25:55 +0000 (03:25 +0100)
committerJann Horn <jann@thejh.net>
Sun, 24 Nov 2013 02:25:55 +0000 (03:25 +0100)
tools/freq_measure.c [new file with mode: 0644]

diff --git a/tools/freq_measure.c b/tools/freq_measure.c
new file mode 100644 (file)
index 0000000..4faaa5d
--- /dev/null
@@ -0,0 +1,22 @@
+#include <stdio.h>
+#include <sys/time.h>
+#include <sched.h>
+
+long getms(void) {
+  struct timeval t;
+  gettimeofday(&t, NULL);
+  return t.tv_sec * 1024 + t.tv_usec/1024;
+}
+
+int main(void) {
+  setbuf(stdout, NULL);
+  while (1) {
+    int c = 0;
+    long t0 = getms();
+    do {
+      c++;
+      sched_yield();
+    } while (getms()<t0+10);
+    printf("%d\n", c);
+  }
+}