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:
60
m1/perf/main.c
Normal file
60
m1/perf/main.c
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user