⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 teststd.c

📁 it is used to generate random number to simulate the conmmunication scheme, very useful
💻 C
字号:
/* testStd.c                                  */
/* Test speed of the standard rand() function */
/* Richard J. Wagner  13 May 2003             */

/* This is free, unrestricted software void of any warranty. */

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

long i;
unsigned long junk;
clock_t start;
clock_t stop;

int main(void)
{
	printf( "Testing speed of standard rand() function\n" );
	printf( "\nTest of time to generate 300 million random integers:\n" );
	srand( 4357U );
	start = clock();
	for( i = 0; i < 300000000; ++i )
	{
		junk = rand();
	}
	stop = clock();
	printf( "Time elapsed = " );
	printf( "%8.3f", (double)( stop - start ) / CLOCKS_PER_SEC );
	printf( " s\n" );
	
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -