Well the C source does not compile on a current update, 19-01-2020, Linux Mint 19 using gcc 7.4.0 so here is a completely simplified and modified version for gcc 4.2.1 and 7.4.0...
The printf function will need to edited for it to work.
It is set up for Linux, (Mint 19), using gcc 7.4.0.
You can still leave to original as it is for OSX 10.14.6+ as it won't affect the performance at all, but you can edit this in instead and have both capable with the minor alteration shown...
Last edited by wisecracker; 01-19-2020 at 06:46 PM..
Reason: Copy and paste error...
How to generate a random integer with specific range(for example, from 1 to 1000)?
Also, how to convert a floating point number into a integer? (2 Replies)
I want to be able to generate a random number within a korn shell script..
Preferably i would like to be able to state how many digits should be in this random number... ie 4 digits or 5 digits etc
Any ideas? (2 Replies)
I saw this formula to generate random number between two specified values in shell script.the following.
$(((RANDOM%(max-min+divisibleBy))/divisibleBy*divisibleBy+min))
Give a example in book.
Generate random number between 6 and 30.like this.
$(((RANDOM%30/3+1)*3))
But I have a... (1 Reply)
Hi All,
I have extracted some report from database for few activities done.
Now I have a requirement to add some random time(In range of 10-35) in front of each activity.
Can be generated random numbers in any bash/sh shell within a given number range, let's say in between 10-30.
... (10 Replies)
Hi,
i want to check if a variable var1 is not a or b or c
pseudo code:
If NOT (var1 = a or var1 = b or var1 = c)
then
...
fi
I want to use POSIX complaint Korn shell, and for string comparison
For the following code, logical.sh
#!/usr/bin/ksh
var="j"
echo "Var : $var"
if ! { || ||... (12 Replies)
Dear all,
I have a question. I have a txt file say 4000 rows X 1800 Column. I 'd like to creat a new column as the first column which is a column of random numbers (n=4000)
thanks a lot!
Lin (2 Replies)
Hi,
Is anybody experience generate a pair of random number by using awk command?
I wanna to generate a pair of random number (range from 1 to 4124) and repeats it 416 times.
Desired output
2 326
123 1256
341 14
3245 645
.
.
.
I did write the below command:
awk... (5 Replies)
Hi Guys and gals...
As you know I am getting to grips with POSIX and hit this stumbling block.
Generating two random numbers 0 to 255 POSIXly. Speed in not important hence the 'sleep 1' command.
I have done a demo that works, but it sure is ugly! Is there a better way?
#!/bin/sh
# Random... (12 Replies)
Hi all...
This is just a fun project to see if it is possible to get a square root of a positive integer from 1 to 9200000 to 6 decimal places on a 64 bit architecture machine.
It is coded around dash and the results show the values from 0 to 10000.
Complex numbers can easily be catered for by... (3 Replies)
Discussion started by: wisecracker
3 Replies
LEARN ABOUT DEBIAN
gguslumber
ggCurTime(3) GGI ggCurTime(3)NAME
ggCurTime, ggUSleep, ggUSlumber - Portable Time Routines
SYNOPSIS
#include <ggi/gg.h>
int ggCurTime(struct timeval *tv);
int ggUSleep(int32_t usecs);
void ggUSlumber(int32_t usecs);
DESCRIPTION
ggCurTime fills the timeval structure pointed to by tv with the current time to the best precision available on the executing platform.
ggUSleep sleeps for at least usecs microseconds, to the best precision available on the executing platform, but may be woken up by a signal
or other unspecified condition. It is not guaranteed that ggUSleep will wake up prematurely for any specific reason. It is mainly useful
for points where the main objective is to avoid using CPU resources, not to perform accurate timing.
ggUSlumber does the same thing as ggUSleep, but is guaranteed not to return until the allotted time has elapsed. It is slightly less effi-
cient than ggUSleep with reguard to CPU utilization.
All times represent wall-clock (real, versus processor) times.
The above routines are often simple macros rather than functions, and as such should not be used by reference.
The above functions are threadsafe, but are not guaranteed to be safe to use in a thread that may be cancelled during their execution.
They are also not guaranteed to be safe to use in special contexts such as LibGG task handlers, signal handlers and asyncronous procedure
calls.
RETURN VALUE
ggCurTime returns GGI_OK on success, or a negative value on failure. On Windows, this function will never report a failure. On platforms
where gettimeofday(2) is used, the error code is the one returned by gettimeofday.
ggUSleep returns GGI_OK when the alloted time interval has elapsed, or a non-zero value if the sleep was interrupted. On platforms where
usleep(3) is used, the error code is the one return by usleep.
EXAMPLE
A demonstration on how to measure a framerate.
struct timeval start, stop, diff;
long time_of_frame = 1;
int framerate;
...
ggCurTime(&start);
/* do something here, i.e. render and display a frame */
ggCurTime(&stop);
diff.tv_sec = stop_tv.tv_sec - start_tv.tv_sec;
diff.tv_usec = stop_tv.tv_usec - start_tv.tv_usec;
if (diff.tv_usec < 0) {
diff.tv_usec += 1000000;
diff.tv_sec--;
}
time_of_frame = diff.tv_sec * 1000 + diff.tv_usec / 1000;
if (time_of_frame == 0)
time_of_frame = 1; /* CPU too fast? */
printf("framerate: %i
", 1000 / time_of_framerate);
SEE ALSO gettimeofday(2), usleep(3)libgg-1.0.x 2005-08-26 ggCurTime(3)