Sha256: 6860fdbdd18853465d06f00834fafc40ebc5ba6ba4fc8dc5ebb3c4bfcd228aea

Contents?: true

Size: 617 Bytes

Versions: 3

Compression:

Stored size: 617 Bytes

Contents

#include <time.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/sysctl.h>
#include "osfreq.c"

static double cpufrequency = 0;

static void init(void)
{
  cpufrequency = osfreq();
}

long long cpucycles_monotoniccpuinfo(void)
{
  double result;
  struct timespec t;
  if (!cpufrequency) init();
  clock_gettime(CLOCK_MONOTONIC,&t);
  result = t.tv_nsec;
  result *= 0.000000001;
  result += (double) t.tv_sec;
  result *= cpufrequency;
  return result;
}

long long cpucycles_monotoniccpuinfo_persecond(void)
{
  if (!cpufrequency) init();
  return cpufrequency;
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby_nacl-0.1.2 ext/ruby_nacl/NaCl/cpucycles/monotoniccpuinfo.c
ruby_nacl-0.1.1 ext/ruby_nacl/NaCl/cpucycles/monotoniccpuinfo.c
ruby_nacl-0.1.0 ext/ruby_nacl/NaCl/cpucycles/monotoniccpuinfo.c