Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternative implementation clock_gettime. #260

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -22,15 +22,19 @@
#include <stdlib.h>
#include <string>
#include <time.h>
#include <chrono>

#include "gumbo.h"

static const int kNumReps = 10;

static uint64_t get_time() {
struct timespec time;
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time);
return time.tv_sec * 1000000000 + time.tv_nsec;
using namespace std::chrono;

high_resolution_clock::time_point now = high_resolution_clock::now();
high_resolution_clock::duration duration = now.time_since_epoch();

return duration_cast<std::chrono::nanoseconds>(duration).count();
}

int main(int argc, char** argv) {
ProTip! Use n and p to navigate between commits in a pull request.