test how random/sorted dataset affect speed.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
e6dfd24678
commit
f26a23b409
@ -1,3 +1,4 @@
|
|||||||
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
@ -84,8 +85,15 @@ int main()
|
|||||||
srand(time(nullptr));
|
srand(time(nullptr));
|
||||||
for (int i = 0; i < SIZE; i++)
|
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);
|
func1(arr);
|
||||||
func2(arr);
|
func2(arr);
|
||||||
func_likely(arr);
|
func_likely(arr);
|
||||||
|
Loading…
Reference in New Issue
Block a user