<commit_before>#define _DEFAULT_SOURCE

#include <stdlib.h>
#include <stdio.h>
#include <stdint.h> 
#include <stdbool.h> 
#include <string.h>
#include <sys/types.h>
#include <errno.h>
#include <assert.h>

#include <papi.h>

#include <time.h>

#include "measure.h"

__attribute__ ((visibility("default"))) int N_EVENTS = 11;
int          **events;

__attribute__ ((visibility("default")))
int measure(char *test, char *name, char *size, testfunc fp, void *up, int ups) {
	int res; 
	uint8_t  i, j;
	uint64_t total_ns, total_s;
	struct timespec begin, end;
	bool timemeasured = false; 
	long long meas[2] = {0, 0};

	printf("%s,%s,%s", test, name, size);

	for (i = 0; i < N_EVENTS; i++) {
		if (!timemeasured) {
			clock_gettime(CLOCK_REALTIME, &begin);
		}

		if ((res = PAPI_start_counters(&events[i][1], events[i][0])) != PAPI_OK) {
			for (j = 1; j <= events[i][0]; j++) {
				printf(",0");
			}
			continue;
		};

		for (j = 0; j < ups; j++) {
			(fp)(up);
		}

		PAPI_stop_counters(meas, events[i][0]);

		if (!timemeasured) {
			clock_gettime(CLOCK_REALTIME, &end);

			if (begin.tv_nsec <= end.tv_nsec) {
				total_ns = end.tv_nsec - begin.tv_nsec;
				total_s  = end.tv_sec  - begin.tv_sec;
			} else {
				total_ns = end.tv_nsec + (1e9 - begin.tv_nsec);
				total_s  = end.tv_sec - begin.tv_sec - 1;
			}

			uint64_t total = total_s * 1e9 + total_ns;
			printf(",%f", (double)total/ups);
			timemeasured = true;
		}

		for (j = 1; j <= events[i][0]; j++) {
			printf(",%lld", meas[j-1]/ups);
		}
	}

	printf("\n");

	return 0;
}
<commit_msg>Made measure multi visible<commit_after>#define _DEFAULT_SOURCE

#include <stdlib.h>
#include <stdio.h>
#include <stdint.h> 
#include <stdbool.h> 
#include <string.h>
#include <sys/types.h>
#include <errno.h>
#include <assert.h>

#include <papi.h>

#include <time.h>

#include "measure.h"

__attribute__ ((visibility("default"))) int N_EVENTS = 11;
int          **events;

__attribute__ ((visibility("default")))
int measure(char *test, char *name, char *size, testfunc fp, void *up, int ups) {
	int res; 
	uint8_t  i, j;
	uint64_t total_ns, total_s;
	struct timespec begin, end;
	bool timemeasured = false; 
	long long meas[2] = {0, 0};

	printf("%s,%s,%s", test, name, size);

	for (i = 0; i < N_EVENTS; i++) {
		if (!timemeasured) {
			clock_gettime(CLOCK_REALTIME, &begin);
		}

		if ((res = PAPI_start_counters(&events[i][1], events[i][0])) != PAPI_OK) {
			for (j = 1; j <= events[i][0]; j++) {
				printf(",0");
			}
			continue;
		};

		for (j = 0; j < ups; j++) {
			(fp)(up);
		}

		PAPI_stop_counters(meas, events[i][0]);

		if (!timemeasured) {
			clock_gettime(CLOCK_REALTIME, &end);

			if (begin.tv_nsec <= end.tv_nsec) {
				total_ns = end.tv_nsec - begin.tv_nsec;
				total_s  = end.tv_sec  - begin.tv_sec;
			} else {
				total_ns = end.tv_nsec + (1e9 - begin.tv_nsec);
				total_s  = end.tv_sec - begin.tv_sec - 1;
			}

			uint64_t total = total_s * 1e9 + total_ns;
			printf(",%f", (double)total/ups);
			timemeasured = true;
		}

		for (j = 1; j <= events[i][0]; j++) {
			printf(",%lld", meas[j-1]/ups);
		}
	}

	printf("\n");

	return 0;
}

__attribute__ ((visibility("default")))
{'fraction_non_alphanumeric': 0.1889064976228209, 'fraction_numerical': 0.01711568938193344, 'mean_word_length': 3.4829545454545454, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3155434', 'n_tokens_mistral': 1502, 'n_tokens_neox': 1329, 'n_words': 293}