1
0
mirror of git://projects.qi-hardware.com/wernermisc.git synced 2025-04-21 12:27:27 +03:00

m1/perf/: main.c was missing. Added on-going work.

This commit is contained in:
Werner Almesberger
2011-09-17 23:02:34 -03:00
parent 001ca49cc6
commit 9a5a22eda5
3 changed files with 542 additions and 0 deletions

60
m1/perf/main.c Normal file
View File

@@ -0,0 +1,60 @@
#include <stdlib.h>
#include <stdio.h>
#include "compiler.h"
#define BUF_SIZE 1000000
static void report(const char *s)
{
fprintf(stderr, "%s\n", s);
}
static void usage(const char *name)
{
fprintf(stderr, "usage: %s patch-file [loops]\n", name);
exit(1);
}
int main(int argc, char **argv)
{
char buf[BUF_SIZE];
const char *name;
FILE *file;
size_t got;
int loops = 1;
int i;
switch (argc) {
case 2:
break;
case 3:
loops = atoi(argv[2]);
break;
default:
usage(*argv);
}
name = argv[1];
file = fopen(name, "r");
if (!file) {
perror(name);
exit(1);
}
got = fread(buf, sizeof(buf)-1, 1, file);
if (got < 0) {
perror(name);
exit(1);
}
buf[got] = 0;
fclose(file);
for (i = 0; i != loops; i++)
patch_compile(buf, report);
return 0;
}