projects
/
tools.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(from parent 1:
4646ef7
)
add freq_measure
author
Jann Horn
<jann@thejh.net>
Sun, 24 Nov 2013 02:25:55 +0000
(
03:25
+0100)
committer
Jann Horn
<jann@thejh.net>
Sun, 24 Nov 2013 02:25:55 +0000
(
03:25
+0100)
tools/freq_measure.c
[new file with mode: 0644]
patch
|
blob
diff --git a/tools/freq_measure.c
b/tools/freq_measure.c
new file mode 100644
(file)
index 0000000..
4faaa5d
--- /dev/null
+++ b/
tools/freq_measure.c
@@ -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);
+ }
+}