summaryrefslogtreecommitdiff
path: root/bench
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-11-17 20:53:32 -0800
committerOri Bernstein <ori@eigenstate.org>2015-11-17 20:53:32 -0800
commit8531896f8d21ba1e727262aaf5cd96043590b480 (patch)
tree7c01441755f56ab66d33c37d3ac41642ddc46c0b /bench
parentc20862cda53c711fe476f6c7d0f6631af47a4933 (diff)
downloadmc-8531896f8d21ba1e727262aaf5cd96043590b480.tar.gz
MEGAPATCH: Tabification.
Tabs > spaces. By 4 spaces, to be precise. Let's use them.
Diffstat (limited to 'bench')
-rw-r--r--bench/runner.c84
1 files changed, 0 insertions, 84 deletions
diff --git a/bench/runner.c b/bench/runner.c
deleted file mode 100644
index a43d65b..0000000
--- a/bench/runner.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/* written in C instead of Myrddin because I don't have FP in Myrddin yet... */
-#include <stdlib.h>
-#include <stdio.h>
-
-#include <fcntl.h>
-#include <unistd.h>
-#include <err.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <sys/wait.h>
-
-#define Nsamp 10
-
-double run(char *prog)
-{
- struct rusage ru;
- double sec, usec;
- int in, out;
- char *cmd[2];
- int pid;
- int status;
-
- sec = 0;
- usec = 0;
- pid = fork();
- if (pid < 0) {
- err(1, "Could not fork\n");
- } else if (pid == 0) {
- if ((in = open("/dev/zero", O_RDONLY)) < 0)
- err(1, "could not open /dev/zero");
- if ((out = open("/dev/null", O_WRONLY)) < 0)
- err(1, "could not open /dev/null");
- if (dup2(in, 0) < 0)
- err(1, "could not reopen stdin");
- if (dup2(out, 1) < 0)
- err(1, "could not reopen stdout");
-
- cmd[0] = prog;
- cmd[1] = NULL;
- execv(prog, cmd);
- err(1, "Failed to exec\n");
- } else {
- wait4(pid, &status, 0, &ru);
- if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
- err(1, "Subprogram failed to execute\n");
- sec = ru.ru_utime.tv_sec;
- usec = ru.ru_utime.tv_usec / (1000.0 * 1000.0);
- }
- return sec + usec;
-}
-
-double timed_run(char *prog)
-{
- double avg, m, d, x;
- int i, n;
-
- avg = 0;
- m = 0;
- n = 0;
- for (i = 0; i < Nsamp; i++) {
- n++;
- x = run(prog);
- d = (x - avg);
- avg += d/n;
- m = m + d*(x - avg);
- }
- printf("%s:\t%fs (σ^2: %f)\n", prog, avg, m/(n-1));
- return avg;
-}
-
-int main(int argc, char **argv)
-{
- double tot;
- int i;
-
- printf("Running benchmarks: %d samples per binary\n", Nsamp);
- tot = 0;
- for (i = 1; i < argc; i++)
- tot += timed_run(argv[i]);
- printf("total:\t%fs\n", tot);
- return 0;
-}
-