Skip to content

Commit 8e44e83

Browse files
committed
fixes for WSL
1 parent f05c53d commit 8e44e83

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# CXX=g++-8
22
# CC=gcc-8
33

4+
ARCH := haswell
5+
46
ENABLE_TIMER := 0
5-
COMMONFLAGS := -O3 -g -march=haswell -DENABLE_TIMER=$(ENABLE_TIMER) -Wall -Wextra -Wno-unused-parameter
7+
COMMONFLAGS := -O3 -g -march=$(ARCH) -DENABLE_TIMER=$(ENABLE_TIMER) -Wall -Wextra -Wno-unused-parameter
68
CXXFLAGS := $(COMMONFLAGS) $(EFLAGS) -std=c++11
7-
CFLAGS := $(COMMONFLAGS) $(EFLAGS)
9+
CFLAGS := $(COMMONFLAGS) $(EFLAGS) -std=c99 -Wno-missing-field-initializers
810

911
HEADERS := $(wildcard *.h*)
1012
SRCS := $(wildcard *.cpp *.c)

bench.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
#include "simple-timer.hpp"
1818

19-
2019
inline uint64_t random_range(uint64_t range) {
2120
// Fast Random Integer Generation in an Interval,
2221
// ACM Transactions on Modeling and Computer Simulation 29 (1), 2019
@@ -65,19 +64,22 @@ const size_t range_max = 40000000000ull;
6564
void bench_one(const sort_algo& algo, const uint64_t* input, uint64_t* buffer, size_t size) {
6665
// assert(!is_sorted(input, size));
6766

68-
clock_t before, after;
69-
67+
// clock_t before, after;
68+
int64_t elapsed;
7069
for (int i = 0; i < repeats; i++) {
7170
std::copy(input, input + size, buffer);
7271

73-
before = clock();
72+
// before = clock();
73+
SimpleTimer timer;
7474
algo.fn(buffer, size);
75-
after = clock();
75+
elapsed = timer.elapsedNanos();
76+
// after = clock();
7677
}
7778

7879
assert(is_sorted(buffer, size));
7980

80-
printf(",%*.1f", (int)strlen(algo.name), (after - before) * 1000000000. / size / CLOCKS_PER_SEC);
81+
// printf(",%*.1f", (int)strlen(algo.name), (after - before) * 1000000000. / size / CLOCKS_PER_SEC);
82+
printf(",%*.1f", (int)strlen(algo.name), (double)elapsed / size);
8183

8284
}
8385

0 commit comments

Comments
 (0)