efaea387874eef4dff3db4065d6328824d9677ff
2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; only version 2
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 cycles_t
get_cycles(void)
28 return caa_get_cycles();
31 uint64_t get_cpu_freq(void)
34 struct timeval tvstart
, tvstop
;
35 cycles_t c_before
, c_after
;
36 unsigned long microseconds
;
38 memset(&tz
, 0, sizeof(tz
));
40 gettimeofday(&tvstart
, &tz
);
41 c_before
= get_cycles();
42 gettimeofday(&tvstart
, &tz
);
46 gettimeofday(&tvstop
, &tz
);
47 c_after
= get_cycles();
48 gettimeofday(&tvstop
, &tz
);
50 microseconds
= ((tvstop
.tv_sec
- tvstart
.tv_sec
) * 1000000) +
51 (tvstop
.tv_usec
- tvstart
.tv_usec
);
53 return (uint64_t) ((c_after
- c_before
) / microseconds
);
This page took 0.041955 seconds and 4 git commands to generate.