test how random/sorted dataset affect speed.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
wangjiacai 2023-02-12 14:59:21 +08:00
parent e6dfd24678
commit f26a23b409

View File

@ -1,3 +1,4 @@
#include <algorithm>
#include <iostream>
#include <sys/time.h>
@ -84,8 +85,15 @@ int main()
srand(time(nullptr));
for (int i = 0; i < SIZE; i++)
{
arr[i] = (rand() % (RANGE + 1)) + 0.499 * RANGE;
arr[i] = (rand() % (RANGE + 1));
}
cout << "random dataset:" << endl;
func1(arr);
func2(arr);
func_likely(arr);
func_unlikely(arr);
sort(arr, arr + SIZE);
cout << "sorted dataset:" << endl;
func1(arr);
func2(arr);
func_likely(arr);