1
0
mirror of git://projects.qi-hardware.com/wernermisc.git synced 2024-12-24 10:23:20 +02:00
wernermisc/m1/perf/main.c

61 lines
784 B
C
Raw Normal View History

#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, 1, sizeof(buf)-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;
}