Closed QzSG closed 6 years ago
Use #include <chrono> instead for more accurate time calculations https://github.com/Psyf/DataStructsAndAlgos-2040C/blob/3c3f0bc478a896d987125fe9e53b59d5a1f8b682/sorting_algos.cpp#L13 Can use std::chrono::steady_clock or std::chrono::high_resolution_clock https://github.com/Psyf/DataStructsAndAlgos-2040C/blob/3c3f0bc478a896d987125fe9e53b59d5a1f8b682/sorting_algos.cpp#L92-L94 Note: Compiler can still move your codes around during optimization, best way is to use some dedicated code metrics tool, or to do an average of n times.
#include <chrono>
std::chrono::steady_clock
std::chrono::high_resolution_clock
Use #include <random> instead of C's srand Something like
#include <random>
srand
random_device rd; mt19937 mt(rd()); uniform_int_distribution<int> uni(1, max); int randNum = uni(mt);
Please do not use both methods if cryptographic security is needed, use a CSPRNG instead
Sample code might not work, coded on a portable potato, also screw indentation
Mostly just to reccomend using C++11 STLs
Use
#include <chrono>
instead for more accurate time calculations https://github.com/Psyf/DataStructsAndAlgos-2040C/blob/3c3f0bc478a896d987125fe9e53b59d5a1f8b682/sorting_algos.cpp#L13 Can usestd::chrono::steady_clock
orstd::chrono::high_resolution_clock
https://github.com/Psyf/DataStructsAndAlgos-2040C/blob/3c3f0bc478a896d987125fe9e53b59d5a1f8b682/sorting_algos.cpp#L92-L94 Note: Compiler can still move your codes around during optimization, best way is to use some dedicated code metrics tool, or to do an average of n times.Use
#include <random>
instead of C'ssrand
Something likePlease do not use both methods if cryptographic security is needed, use a CSPRNG instead
Sample code might not work, coded on a portable potato, also screw indentation