[llvm-commits] [test-suite] r121239 - in /test-suite/trunk/MultiSource/Examples/Noisy: ./ Makefile noisy.c
Daniel Dunbar
daniel at zuster.org
Tue Dec 7 23:28:17 PST 2010
Author: ddunbar
Date: Wed Dec 8 01:28:17 2010
New Revision: 121239
URL: http://llvm.org/viewvc/llvm-project?rev=121239&view=rev
Log:
nt: Add a silly example test useful for testing noise estimation stuff.
Added:
test-suite/trunk/MultiSource/Examples/Noisy/
test-suite/trunk/MultiSource/Examples/Noisy/Makefile
test-suite/trunk/MultiSource/Examples/Noisy/noisy.c
Added: test-suite/trunk/MultiSource/Examples/Noisy/Makefile
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Examples/Noisy/Makefile?rev=121239&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Examples/Noisy/Makefile (added)
+++ test-suite/trunk/MultiSource/Examples/Noisy/Makefile Wed Dec 8 01:28:17 2010
@@ -0,0 +1,5 @@
+LEVEL = ../../..
+PROG = Noisy
+CPPFLAGS =
+LDFLAGS =
+include ../../Makefile.multisrc
Added: test-suite/trunk/MultiSource/Examples/Noisy/noisy.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Examples/Noisy/noisy.c?rev=121239&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Examples/Noisy/noisy.c (added)
+++ test-suite/trunk/MultiSource/Examples/Noisy/noisy.c Wed Dec 8 01:28:17 2010
@@ -0,0 +1,30 @@
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+double get_time() {
+ return (double) clock() / CLOCKS_PER_SEC;
+}
+
+int cmp(const void *a, const void *b) {
+ return 0;
+}
+
+int main() {
+ static int big_array[1 << 12] = { 0 };
+ double base_time = .2, noise_range = .1;
+ double delay, start_time;
+
+ srand48(clock());
+ delay = base_time + noise_range * drand48();
+
+ // We spin here to make sure we consume user time.
+ start_time = get_time();
+ while (get_time() < start_time + delay) {
+ // Ok until someone on the backend gets crazy.
+ qsort(big_array, sizeof(big_array) / sizeof(big_array[0]),
+ sizeof(big_array[0]), cmp);
+ }
+
+ return 0;
+}
More information about the llvm-commits
mailing list