Factorisation.
This commit is contained in:
1 parent
f8ff180b94
commit
30484f4291
7 files changed
+37
-186
No files matched your search
+1
-31
@@ -10,37 +10,7 @@
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
unsigned long g_result;
|
||||
|
||||
static unsigned long long
|
||||
cputime (void)
|
||||
{
|
||||
struct rusage rus;
|
||||
getrusage (0, &rus);
|
||||
return rus.ru_utime.tv_sec * 1000000ULL + rus.ru_utime.tv_usec;
|
||||
}
|
||||
|
||||
static unsigned int randValue = 0;
|
||||
static void rand_init(void)
|
||||
{
|
||||
randValue = 0;
|
||||
}
|
||||
static unsigned int rand_get(void)
|
||||
{
|
||||
randValue = randValue * 31421U + 6927U;
|
||||
return randValue;
|
||||
}
|
||||
|
||||
static void test_function(const char str[], size_t n, void (*func)(size_t))
|
||||
{
|
||||
unsigned long long start, end;
|
||||
// (*func)(n);
|
||||
start = cputime();
|
||||
(*func)(n);
|
||||
end = cputime();
|
||||
end = (end - start) / 1000U;
|
||||
printf ("%s %Lu ms for n = %lu\n", str, end, n);
|
||||
}
|
||||
#include "common.h"
|
||||
|
||||
/********************************************************************************************/
|
||||
|
||||
|
||||
+1
-31
@@ -13,37 +13,7 @@
|
||||
#include "khash.h"
|
||||
#include "ksort.h"
|
||||
|
||||
unsigned long g_result;
|
||||
|
||||
static unsigned long long
|
||||
cputime (void)
|
||||
{
|
||||
struct rusage rus;
|
||||
getrusage (0, &rus);
|
||||
return rus.ru_utime.tv_sec * 1000000ULL + rus.ru_utime.tv_usec;
|
||||
}
|
||||
|
||||
static unsigned int randValue = 0;
|
||||
static void rand_init(void)
|
||||
{
|
||||
randValue = 0;
|
||||
}
|
||||
static unsigned int rand_get(void)
|
||||
{
|
||||
randValue = randValue * 31421U + 6927U;
|
||||
return randValue;
|
||||
}
|
||||
|
||||
static void test_function(const char str[], size_t n, void (*func)(size_t))
|
||||
{
|
||||
unsigned long long start, end;
|
||||
// (*func)(n);
|
||||
start = cputime();
|
||||
(*func)(n);
|
||||
end = cputime();
|
||||
end = (end - start) / 1000U;
|
||||
printf ("%s %Lu ms for n = %lu\n", str, end, n);
|
||||
}
|
||||
#include "common.h"
|
||||
|
||||
/********************************************************************************************/
|
||||
|
||||
|
||||
@@ -11,37 +11,7 @@
|
||||
|
||||
#include "dynamic.h"
|
||||
|
||||
unsigned long g_result;
|
||||
|
||||
static unsigned long long
|
||||
cputime (void)
|
||||
{
|
||||
struct rusage rus;
|
||||
getrusage (0, &rus);
|
||||
return rus.ru_utime.tv_sec * 1000000ULL + rus.ru_utime.tv_usec;
|
||||
}
|
||||
|
||||
static unsigned int randValue = 0;
|
||||
static void rand_init(void)
|
||||
{
|
||||
randValue = 0;
|
||||
}
|
||||
static unsigned int rand_get(void)
|
||||
{
|
||||
randValue = randValue * 31421U + 6927U;
|
||||
return randValue;
|
||||
}
|
||||
|
||||
static void test_function(const char str[], size_t n, void (*func)(size_t))
|
||||
{
|
||||
unsigned long long start, end;
|
||||
// (*func)(n);
|
||||
start = cputime();
|
||||
(*func)(n);
|
||||
end = cputime();
|
||||
end = (end - start) / 1000U;
|
||||
printf ("%s %Lu ms for n = %lu\n", str, end, n);
|
||||
}
|
||||
#include "common.h"
|
||||
|
||||
/********************************************************************************************/
|
||||
|
||||
|
||||
+1
-31
@@ -15,37 +15,7 @@
|
||||
#include "m-mempool.h"
|
||||
#include "m-string.h"
|
||||
|
||||
unsigned long g_result;
|
||||
|
||||
static unsigned long long
|
||||
cputime (void)
|
||||
{
|
||||
struct rusage rus;
|
||||
getrusage (0, &rus);
|
||||
return rus.ru_utime.tv_sec * 1000000ULL + rus.ru_utime.tv_usec;
|
||||
}
|
||||
|
||||
static unsigned int randValue = 0;
|
||||
static void rand_init(void)
|
||||
{
|
||||
randValue = 0;
|
||||
}
|
||||
static unsigned int rand_get(void)
|
||||
{
|
||||
randValue = randValue * 31421U + 6927U;
|
||||
return randValue;
|
||||
}
|
||||
|
||||
static void test_function(const char str[], size_t n, void (*func)(size_t))
|
||||
{
|
||||
unsigned long long start, end;
|
||||
// (*func)(n);
|
||||
start = cputime();
|
||||
(*func)(n);
|
||||
end = cputime();
|
||||
end = (end - start) / 1000U;
|
||||
printf ("%s %Lu ms for n = %lu (r=%lu)\n", str, end, n, g_result);
|
||||
}
|
||||
#include "common.h"
|
||||
|
||||
/********************************************************************************************/
|
||||
|
||||
|
||||
+1
-31
@@ -17,37 +17,7 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
unsigned long g_result;
|
||||
|
||||
static unsigned long long
|
||||
cputime (void)
|
||||
{
|
||||
struct rusage rus;
|
||||
getrusage (0, &rus);
|
||||
return rus.ru_utime.tv_sec * 1000000ULL + rus.ru_utime.tv_usec;
|
||||
}
|
||||
|
||||
static unsigned int randValue = 0;
|
||||
static void rand_init(void)
|
||||
{
|
||||
randValue = 0;
|
||||
}
|
||||
static unsigned int rand_get(void)
|
||||
{
|
||||
randValue = randValue * 31421U + 6927U;
|
||||
return randValue;
|
||||
}
|
||||
|
||||
static void test_function(const char str[], size_t n, void (*func)(size_t))
|
||||
{
|
||||
unsigned long long start, end;
|
||||
// (*func)(n);
|
||||
start = cputime();
|
||||
(*func)(n);
|
||||
end = cputime();
|
||||
end = (end - start) / 1000U;
|
||||
printf ("%s %Lu ms for n = %lu\n", str, end, n);
|
||||
}
|
||||
#include "common.h"
|
||||
|
||||
/********************************************************************************************/
|
||||
|
||||
|
||||
+1
-31
@@ -20,37 +20,7 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
unsigned long g_result;
|
||||
|
||||
static unsigned long long
|
||||
cputime (void)
|
||||
{
|
||||
struct rusage rus;
|
||||
getrusage (0, &rus);
|
||||
return rus.ru_utime.tv_sec * 1000000ULL + rus.ru_utime.tv_usec;
|
||||
}
|
||||
|
||||
static unsigned int randValue = 0;
|
||||
static void rand_init(void)
|
||||
{
|
||||
randValue = 0;
|
||||
}
|
||||
static unsigned int rand_get(void)
|
||||
{
|
||||
randValue = randValue * 31421U + 6927U;
|
||||
return randValue;
|
||||
}
|
||||
|
||||
static void test_function(const char str[], size_t n, void (*func)(size_t))
|
||||
{
|
||||
unsigned long long start, end;
|
||||
// (*func)(n);
|
||||
start = cputime();
|
||||
(*func)(n);
|
||||
end = cputime();
|
||||
end = (end - start) / 1000U;
|
||||
printf ("%s %Lu ms for n = %lu\n", str, end, n);
|
||||
}
|
||||
#include "common.h"
|
||||
|
||||
/********************************************************************************************/
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
unsigned long g_result;
|
||||
|
||||
static unsigned long long
|
||||
cputime (void)
|
||||
{
|
||||
struct rusage rus;
|
||||
getrusage (0, &rus);
|
||||
return rus.ru_utime.tv_sec * 1000000ULL + rus.ru_utime.tv_usec;
|
||||
}
|
||||
|
||||
static unsigned int randValue = 0;
|
||||
static void rand_init(void)
|
||||
{
|
||||
randValue = 0;
|
||||
}
|
||||
static unsigned int rand_get(void)
|
||||
{
|
||||
randValue = randValue * 31421U + 6927U;
|
||||
return randValue;
|
||||
}
|
||||
|
||||
static void test_function(const char str[], size_t n, void (*func)(size_t))
|
||||
{
|
||||
unsigned long long start, end;
|
||||
// (*func)(n);
|
||||
start = cputime();
|
||||
(*func)(n);
|
||||
end = cputime();
|
||||
end = (end - start) / 1000U;
|
||||
printf ("%s %Lu ms for n = %lu\n", str, end, n);
|
||||
}
|
||||
Reference in new issue
Block a user