benches, optimizations for sin and cos
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
#ifndef COM_TIMER_H
|
||||
#define COM_TIMER_H
|
||||
|
||||
#include "../def.h"
|
||||
#include <stdint.h>
|
||||
|
||||
/* Global monotonic counter, meaning it always increases. Not applicable for
|
||||
* getting "real" time, which the game shouldn't be aware of anyways. */
|
||||
uint64_t com_timer_count_ns(void);
|
||||
|
||||
/* Output elapsed time against previous com_timer_count_ns() result. */
|
||||
void com_timer_profile(uint64_t starttime, const char *what);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,17 @@
|
||||
#include "timer.h"
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#define __USE_POSIX199309 1
|
||||
#include <time.h>
|
||||
|
||||
uint64_t com_timer_count_ns(void) {
|
||||
struct timespec time;
|
||||
clock_gettime(CLOCK_MONOTONIC, &time);
|
||||
return time.tv_sec * 1000000000 + time.tv_nsec;
|
||||
}
|
||||
|
||||
void com_timer_profile(uint64_t starttime, const char *what) {
|
||||
uint64_t const endtime = com_timer_count_ns();
|
||||
uint64_t const diff = endtime - starttime;
|
||||
printf("profile \"%s\" took %fms\n", what, (double)diff / 1000000);
|
||||
}
|
||||
Reference in New Issue
Block a user