Compatibility with Windows platform.

This commit is contained in:
Patrick Pelissier committed 2017-07-26 21:12:35 +02:00
1 parent b49e286ae2
commit 8f33273d7e
14 files changed
+53 -42

No files matched your search

-3
View File
@@ -3,9 +3,6 @@
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <sys/types.h>
#include <sys/resource.h>
#include <sys/time.h>
#include "array.h"
#include "slist.h"
-3
View File
@@ -15,9 +15,6 @@
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <sys/types.h>
#include <sys/resource.h>
#include <sys/time.h>
#include "flat_hash_map.hpp"
-3
View File
@@ -4,9 +4,6 @@
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <sys/types.h>
#include <sys/resource.h>
#include <sys/time.h>
#include <glib.h>
-3
View File
@@ -14,9 +14,6 @@
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <sys/types.h>
#include <sys/resource.h>
#include <sys/time.h>
#include "src/hopscotch_map.h"
-3
View File
@@ -3,9 +3,6 @@
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <sys/types.h>
#include <sys/resource.h>
#include <sys/time.h>
#include "kvec.h"
#include "klist.h"
-3
View File
@@ -5,9 +5,6 @@
#include <stdbool.h>
#include <string.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/resource.h>
#include <sys/time.h>
#include "dynamic.h"
-3
View File
@@ -3,9 +3,6 @@
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <sys/types.h>
#include <sys/resource.h>
#include <sys/time.h>
#include "m-array.h"
#include "m-list.h"
-3
View File
@@ -4,9 +4,6 @@
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <sys/types.h>
#include <sys/resource.h>
#include <sys/time.h>
#include <assert.h>
#include "qlibc/qlibc.h"
-3
View File
@@ -11,9 +11,6 @@
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <sys/types.h>
#include <sys/resource.h>
#include <sys/time.h>
using namespace std;
-3
View File
@@ -14,9 +14,6 @@
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <sys/types.h>
#include <sys/resource.h>
#include <sys/time.h>
#include <sparsepp/spp.h>
-3
View File
@@ -14,9 +14,6 @@
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <sys/types.h>
#include <sys/resource.h>
#include <sys/time.h>
using namespace std;
-3
View File
@@ -4,9 +4,6 @@
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <sys/types.h>
#include <sys/resource.h>
#include <sys/time.h>
#include "tommyds/tommy.h"
-3
View File
@@ -3,9 +3,6 @@
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <sys/types.h>
#include <sys/resource.h>
#include <sys/time.h>
#include <string.h>
#include "include/uthash.h"
+53 -3
View File
@@ -1,4 +1,48 @@
unsigned long g_result;
/*
* M*LIB - common functions for bench module
*
* Copyright (c) 2017, Patrick Pelissier
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* + Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* + Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __COMMON_BENCH__H
#define __COMMON_BENCH__H
#if defined(_WIN32)
/* WINDOWS variant */
#include <windows.h>
static unsigned long long
cputime (void)
{
LARGE_INTEGER freq, val;
QueryPerformanceFrequency(&freq);
QueryPerformanceCounter(&val);
return (unsigned long long) (1000000. * (double) val.QuadPart / (double) freq.QuadPart);
}
#else
/* UNIX variant */
#include <sys/types.h>
#include <sys/resource.h>
#include <sys/time.h>
static unsigned long long
cputime (void)
@@ -8,7 +52,11 @@ cputime (void)
return rus.ru_utime.tv_sec * 1000000ULL + rus.ru_utime.tv_usec;
}
static unsigned int randValue = 0;
#endif
unsigned long g_result;
unsigned int randValue = 0;
static void rand_init(void)
{
randValue = 0;
@@ -27,7 +75,7 @@ static void test_function(const char str[], size_t n, void (*func)(size_t))
(*func)(n);
end = cputime();
end = (end - start) / 1000U;
printf ("%s %Lu ms for n = %lu [r=%lu]\n", str, end, n, g_result);
printf ("%s %lu ms for n = %lu [r=%lu]\n", str, (unsigned long) end, (unsigned long) n, g_result);
}
#if defined(_WIN32)
@@ -63,3 +111,5 @@ static inline int get_cpu_count(void)
return 1;
#endif
}
#endif