Sha256: 1575b5a2fb1e39de16c857a94eedb8e63594e91200b6a4a3e69e720cc49de892

Contents?: true

Size: 723 Bytes

Versions: 3

Compression:

Stored size: 723 Bytes

Contents

#ifdef DEBUG
#ifndef DEBUG_H
#define DEBUG_H

#include <x86intrin.h>
#include <stdio.h>
#include <string.h>

#define CONCAT_(a, b) a##b
#define CONCAT(a,b) CONCAT_(a, b)
#define PROFILE DebugTimer CONCAT(Timer, __COUNTER__)(__func__, __LINE__);

struct DebugTimer {
  char* name;
  unsigned long long counter;
  
  DebugTimer(const char* function_name, int line_number) {
    name = (char*)malloc(200 * sizeof(char));

    strcpy(name, function_name);
    strcat(name, "_");
    snprintf(name + strlen(name), 4, "%d", line_number);

    counter = __rdtsc();
  }

  ~DebugTimer() {
    printf("\n%30s:\t %-10llu", name, __rdtsc() - counter);
    free(name);
    fflush(stdout);
  }
};
#endif
#else
#define PROFILE();
#endif

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fast_statistics-0.2.1 ext/fast_statistics/debug.h
fast_statistics-0.2.0 ext/fast_statistics/debug.h
fast_statistics-0.1.1 ext/fast_statistics/debug.h