Instrument running thread in sort and flush tests

This commit is contained in:
Rodrigo Arias 2023-02-20 18:44:54 +01:00 committed by Rodrigo Arias Mallo
parent a1cc8ba87c
commit 7b80aa6aaf
2 changed files with 10 additions and 67 deletions

View File

@ -1,35 +1,9 @@
/* Copyright (c) 2021-2022 Barcelona Supercomputing Center (BSC) /* Copyright (c) 2021-2023 Barcelona Supercomputing Center (BSC)
* SPDX-License-Identifier: GPL-3.0-or-later */ * SPDX-License-Identifier: GPL-3.0-or-later */
#define _POSIX_C_SOURCE 200112L
#define _GNU_SOURCE #define _GNU_SOURCE
#include <limits.h> #include "instr_ovni.h"
#include <linux/limits.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
#include "compat.h"
#include "ovni.h"
static inline void
init(void)
{
char hostname[HOST_NAME_MAX];
if (gethostname(hostname, HOST_NAME_MAX) != 0) {
perror("gethostname failed");
exit(EXIT_FAILURE);
}
ovni_proc_init(0, hostname, getpid());
ovni_thread_init(gettid());
ovni_add_cpu(0, 0);
}
static void static void
emit(char *mcv, int64_t clock) emit(char *mcv, int64_t clock)
@ -43,7 +17,7 @@ emit(char *mcv, int64_t clock)
int int
main(void) main(void)
{ {
init(); instr_start(0, 1);
/* Leave some room to prevent clashes */ /* Leave some room to prevent clashes */
usleep(100); /* 100000 us */ usleep(100); /* 100000 us */
@ -60,8 +34,7 @@ main(void)
emit("OU]", ovni_clock_now()); emit("OU]", ovni_clock_now());
ovni_flush(); instr_end();
ovni_proc_fini();
return 0; return 0;
} }

View File

@ -1,35 +1,9 @@
/* Copyright (c) 2021-2022 Barcelona Supercomputing Center (BSC) /* Copyright (c) 2021-2023 Barcelona Supercomputing Center (BSC)
* SPDX-License-Identifier: GPL-3.0-or-later */ * SPDX-License-Identifier: GPL-3.0-or-later */
#define _POSIX_C_SOURCE 200112L
#define _GNU_SOURCE #define _GNU_SOURCE
#include <limits.h> #include "instr_ovni.h"
#include <linux/limits.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
#include "compat.h"
#include "ovni.h"
static inline void
init(void)
{
char hostname[HOST_NAME_MAX];
if (gethostname(hostname, HOST_NAME_MAX) != 0) {
perror("gethostname failed");
exit(EXIT_FAILURE);
}
ovni_proc_init(0, hostname, getpid());
ovni_thread_init(gettid());
ovni_add_cpu(0, 0);
}
static void static void
emit(uint8_t *buf, size_t size) emit(uint8_t *buf, size_t size)
@ -43,13 +17,10 @@ emit(uint8_t *buf, size_t size)
int int
main(void) main(void)
{ {
size_t payload_size; instr_start(0, 1);
uint8_t *payload_buf;
init(); size_t payload_size = (size_t) (0.9 * (double) OVNI_MAX_EV_BUF);
uint8_t *payload_buf = calloc(1, payload_size);
payload_size = (size_t) (0.9 * (double) OVNI_MAX_EV_BUF);
payload_buf = calloc(1, payload_size);
if (!payload_buf) { if (!payload_buf) {
perror("calloc failed"); perror("calloc failed");
@ -67,8 +38,7 @@ main(void)
emit(payload_buf, payload_size); emit(payload_buf, payload_size);
/* Flush the last event to disk manually */ /* Flush the last event to disk manually */
ovni_flush(); instr_end();
ovni_proc_fini();
free(payload_buf); free(payload_buf);