Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Stefan Strogin
flac
Commits
451efca2
Commit
451efca2
authored
Sep 02, 2015
by
Erik de Castro Lopo
Browse files
microbench/util.c: Win32 support
parent
98cab352
Changes
1
Hide whitespace changes
Inline
Side-by-side
microbench/util.c
View file @
451efca2
...
...
@@ -29,14 +29,47 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdlib.h>
#include "util.h"
#if defined _WIN32
#include <windows.h>
static
double
counter_diff
(
const
LARGE_INTEGER
*
start
,
const
LARGE_INTEGER
*
end
)
{
LARGE_INTEGER
diff
,
freq
;
QueryPerformanceFrequency
(
&
freq
);
diff
.
QuadPart
=
end
->
QuadPart
-
start
->
QuadPart
;
return
(
double
)
diff
.
QuadPart
/
(
double
)
freq
.
QuadPart
;
}
double
benchmark_function
(
void
(
*
testfunc
)
(
void
),
unsigned
count
)
{
LARGE_INTEGER
start
,
end
;
unsigned
k
;
QueryPerformanceCounter
(
&
start
)
;
for
(
k
=
0
;
k
<
count
;
k
++
)
testfunc
();
QueryPerformanceCounter
(
&
end
)
;
return
counter_diff
(
&
start
,
&
end
)
/
count
;
}
/* benchmark_function */
#else
#define _GNU_SOURCE
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
#include "util.h"
static
double
timespec_diff
(
const
struct
timespec
*
start
,
const
struct
timespec
*
end
)
{
struct
timespec
difftime
;
...
...
@@ -68,6 +101,8 @@ benchmark_function (void (*testfunc) (void), unsigned count)
return
timespec_diff
(
&
start
,
&
end
)
/
count
;
}
/* benchmark_function */
#endif
static
int
double_cmp
(
const
void
*
a
,
const
void
*
b
)
{
const
double
*
pa
=
(
double
*
)
a
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment