Cleaned-up timing code

This commit is contained in:
Arthur Maciel 2021-03-05 22:57:33 -03:00
parent e4eae1cdf9
commit 535f2737b1
2 changed files with 4 additions and 19 deletions

View file

@ -96,12 +96,12 @@ void Cyc_check_bounds(void *data, const char *label, int len, int index)
#ifdef CYC_HIGH_RES_TIMERS
/* High resolution timers */
#include <sys/time.h>
#include <time.h>
long long hrt_get_current()
{
struct timeval tv;
gettimeofday(&tv, NULL); /* TODO: longer-term consider using clock_gettime instead */
long long jiffy = (tv.tv_sec)*1000000LL + tv.tv_usec;
struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
long long jiffy = (now.tv_sec)*1000000LL + now.tv_nsec/1000; // nano->microseconds
return jiffy;
}

View file

@ -26,21 +26,6 @@
make_double(box, 0.0);
clock_gettime(CLOCK_MONOTONIC, &now);
long long jiffy = (now.tv_sec)*1000000LL + now.tv_nsec/1000; // nano->microseconds
/* Future consideration:
mp_int bn_tmp, bn_tmp2, bn_tmp3;
mp_init(&bn_tmp);
mp_init(&bn_tmp2);
mp_init(&bn_tmp3);
Cyc_int2bignum(tv.tv_sec, &bn_tmp);
Cyc_int2bignum(1000000LL, &bn_tmp2);
Cyc_int2bignum(tv.tv_usec, &bn_tmp3);
alloc_bignum(data, box);
mp_mul(&bn_tmp, &bn_tmp2, &bn_tmp);
mp_add(&bn_tmp, &bn_tmp3, &bignum_value(box));
mp_clear(&bn_tmp);
mp_clear(&bn_tmp2);
mp_clear(&bn_tmp3);
*/
double_value(&box) = jiffy;
return_closcall1(data, k, &box); ")
(define-c jiffies-per-second