-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_double.cpp
More file actions
33 lines (28 loc) · 800 Bytes
/
Copy pathtest_double.cpp
File metadata and controls
33 lines (28 loc) · 800 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// SPDX-License-Identifier: MIT
#include <cstdio>
#include <cstdlib>
#include <chrono>
#include <algorithm>
#include "blqs.h"
constexpr int SIZE = 50000000;
double data[SIZE];
double time() {
static auto time0 = std::chrono::high_resolution_clock::now();
auto t = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> diff = t - time0;
return diff.count();
}
int main() {
double t0;
printf("Sorting %d million doubles\n", SIZE / 1000000);
srand(1);
for (int i = 0; i < SIZE; i++) data[i] = rand() / 1024.0;
t0 = time();
blqs::sort(data, data + SIZE);
printf("blqs::sort: %.2fs\n", time() - t0);
srand(1);
for (int i = 0; i < SIZE; i++) data[i] = rand() / 1024.0;
t0 = time();
std::sort(data, data + SIZE);
printf("std::sort: %.2fs\n", time() - t0);
}