On 12/12/2023 1:58 PM, Lord Master wrote:
> On Tuesday, December 12, 2023 at 1:21:58 PM UTC-5, DFS wrote:
>>>
>>> Libbsd is NOT needed! Total idiot!
>> If I don't link libbsd-dev, it won't compile:
>>
>
> Then just add:
>
> #include <stdlib.h>
It was already included.
> Now don't bother me. I hate having to babysit totally incompetent idiots
> that have the atrocious sense of running GNU/Linux on Microslop.
"They concluded that Ubuntu WSL performance was around 94% the speed of
bare metal Ubuntu on the same system overall."
And the vast majority of what I do in Linux now is console code.
So I'm good.
>> $ cat /proc/sys/kernel/random/poolsize
>> 256
>>
>> $ cat /proc/sys/kernel/random/entropy_avail
>> 256
>>
>
> Holy moley! On a real GNU/Linux system the pool would use the Intel
> rdrand to increase entropy blazingly fast.
> In that case, my wonderful and fantastic code would be done
> in a miilisecond.
Wouldn't it be nice if you could write code like me to prove it?
============================================================================
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
//settings
int dates = 2000000;
int beginYear = 1923;
int endYear = 2023;
int years = 100;
//program timing
double elapsedtime(clock_t start) {
return (clock() - (double)start)/CLOCKS_PER_SEC;
}
//DFS
//get random number from within range
int randNbr(int low, int high) {
return (low + rand() / (RAND_MAX / (high - low + 1) + 1));
}
//DFS
//build random date in format YYYY-MM-DD
//number of days in the month
int mdays[12]={31,28,31,30,31,30,31,31,30,31,30,31};
char *genRandDate(void) {
//get year, then random month, then random day from that month
int ryear = randNbr(beginYear, endYear);
int rmth = randNbr(1,12);
int rday = randNbr(1,mdays[rmth-1]);
//leap year calc - executes only if Feb is chosen
if(rmth == 2) {
if(((ryear%4==0) && (ryear%100!=0)) || (ryear%400==0)) {
rday = randNbr(1,29);
}
}
//store,format,return data
char *randDt = malloc(sizeof(char) * 11);
sprintf(randDt,"%d-%02d-%02d",ryear, rmth, rday);
randDt[10] = '\0';
return randDt;
}
int main(void) {
//Feeb
time_t mjd;
struct tm *local_time;
char rnd_date[20];
//timing-related
clock_t start;
//seed rng
srand(time(NULL));
//speed tests
printf("generating random dates...\n");
//DFS
start = clock();
for (int i=1; i<=dates; i++) {
genRandDate();
}
printf("%d DFS dates generated in %.2f seconds\n", dates,
elapsedtime(start));
//Feeb
start = clock();
for (int i=1; i<=dates; i++) {
mjd = ((time_t)(arc4random_uniform(365*years*2)) -
(time_t)(365*years)) * (time_t)86400;
local_time = localtime(&mjd);
strftime(rnd_date, sizeof(rnd_date), "%F", local_time);
}
printf("%d Feeb dates generated in %.2f seconds\n", dates,
elapsedtime(start));
printf("done\n");
return 0;
}
============================================================================
Multiply or divide whatever you claim by the "Feeb Blab Constant" of
296847 and you get the actual result.