clock



time.h

clock_t clock(void);

The clock() function returns an approximation of processor time used by the program.

Note that the time can wrap around. On a 32-bit system where CLOCKS_PER_SEC equals 1000000 this function will return the same value approximately every 72 minutes.

its a Thread safety function

Returns

returns approximate processor time that is consumed by the program since launched, and on failure returns -1.


example program

#include <time.h>
#include <stdio.h>
#include <stdlib.h>

//  gcc -o clock_prg clock_prg.c
// ./clock_prg
int main () 
{
	clock_t clock_start_time;
	clock_t clock_end_time;
	clock_t clock_taken_time;

	clock_start_time = clock();
	printf("clock_start_time = %ld\n", clock_start_time);

	int r = 0;
	int zz = 0;
	while( zz < 999999)
	{
		r = rand();
		zz++;
	}
	
	clock_end_time = clock();
	
	clock_taken_time = (double)(clock_end_time - clock_start_time) / CLOCKS_PER_SEC;
	printf("clock_end_time = %ld, application taken processor time: %f\n", clock_end_time, clock_taken_time);

	return EXIT_SUCCESS;
}

program output:

clock_start_time = 0
clock_end_time = 20000, application taken processor time: 0.000000



strtok

Split string into tokens

posted on 2019-03-17 20:41:48 - C Programming Language Tutorials


zalloc

zalloc is a third party library

posted on 2018-12-12 20:46:30 - C Programming Language Tutorials


math

posted on 2017-12-29 22:52:47 - C Programming Language Tutorials


Prompt Examples

ChatGPT Prompt Examples

posted on 2023-06-21 22:37:19 - ChatGPT Tutorials


Use Cases

Chat GPT Key Use Cases

posted on 2023-06-21 21:03:17 - ChatGPT Tutorials


Prompt Frameworks

Prompt Frameworks

posted on 2023-06-21 19:33:06 - ChatGPT Tutorials