ovni/test_speed.c

57 lines
797 B
C
Raw Normal View History

2021-07-22 12:36:02 +02:00
#include <stdint.h>
#include <stddef.h>
#include <stdio.h>
2021-09-28 12:27:14 +02:00
#include <unistd.h>
2021-07-22 12:36:02 +02:00
#include <sys/types.h>
#include <linux/limits.h>
2021-07-22 12:36:02 +02:00
#include "ovni.h"
2021-09-28 12:27:14 +02:00
#ifndef gettid
# include <sys/syscall.h>
# define gettid() ((pid_t)syscall(SYS_gettid))
#endif
2021-07-22 12:36:02 +02:00
2021-09-28 12:27:14 +02:00
static inline void
init()
{
char hostname[HOST_NAME_MAX];
char *appid;
if(gethostname(hostname, HOST_NAME_MAX) != 0)
{
perror("gethostname failed");
abort();
}
ovni_proc_init(0, hostname, getpid());
ovni_thread_init(gettid());
ovni_add_cpu(0, 0);
}
int main(int argc, char *argv[])
2021-07-22 12:36:02 +02:00
{
struct ovni_ev ev = {0};
2021-09-28 12:27:14 +02:00
int i, n;
if(argv[1] != NULL)
n = atoi(argv[1]);
else
n = 1000;
2021-07-22 12:36:02 +02:00
2021-09-28 12:27:14 +02:00
init();
2021-07-22 12:36:02 +02:00
ovni_ev_set_mcv(&ev, "OB.");
2021-09-28 12:27:14 +02:00
for(i=0; i<n; i++)
2021-07-22 12:36:02 +02:00
{
ovni_clock_update();
ovni_ev(&ev);
2021-07-22 12:36:02 +02:00
}
ovni_flush();
2021-09-28 12:27:14 +02:00
ovni_proc_fini();
2021-07-22 12:36:02 +02:00
return 0;
}