Created
July 14, 2022 06:56
-
-
Save antoinefortin/39ac399b7a5bde3ae26da10b19ef71e0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <intrin.h> | |
#include <cmath> | |
uint64_t rdtsc() { | |
return __rdtsc(); | |
} | |
float random0t1(uint64_t cpuClock) | |
{ | |
float parcels = abs(sin(cpuClock) * cos(sin(cpuClock / 2))); | |
return parcels; | |
} | |
int randomN(uint64_t cpuClock, int s) | |
{ | |
float parcels = abs(sin(cpuClock) * cos(sin(cpuClock / 2))); | |
int res = parcels * s; | |
return res; | |
} | |
int main() | |
{ | |
// debug press enter | |
while (true) | |
{ | |
std::cin.ignore(); | |
uint64_t currClock = rdtsc(); | |
float random = random0t1(currClock); | |
int nr = randomN(currClock, 55); | |
std::cout << currClock << std::endl; | |
std::cout << nr << std::endl; | |
std::cout << random << std::endl; | |
} | |
return 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment