コード例 #1
0
void buffered_string_benchmark(void){

	//basic test to see if BufStringAdd is working at all, should print out <123456abcdefg>
	BufString *a = BufStringNewSize(10/*initial size*/);
	BufStringAdd(a, "123456");
	BufStringAdd(a, "abcdefg");
	DEBUG("Test <%s>\n", a->bs_Buffer);


	for (unsigned int i = 0; i < 25; i++){

		struct timeval start_time, end_time;
		gettimeofday(&start_time, NULL);

		BufString *b = BufStringNewSize(10/*initial size*/);

		for (unsigned int j = 0; j < 100000000; j++){
			BufStringAdd(b, "123456790");
		}
//		DEBUG("Total buffer size %d", b->bs_Size);

		gettimeofday(&end_time, NULL);

		struct timeval duration;
		timeval_subtract(&duration, &end_time, &start_time);

		DEBUG("Iteration %d execution time %ld.%04lds\n", i, duration.tv_sec, duration.tv_usec/1000);

		BufStringDelete(b);

	}
	exit(1);
}
コード例 #2
0
ファイル: fsysphp.c プロジェクト: FriendSoftwareLabs/friendup
BufString *Dir( File *s, const char *path )
{
	char *comm = NULL;
	
	if( ( comm = calloc( strlen( path ) +512, sizeof(char) ) ) != NULL )
	{
		strcpy( comm, s->f_Name );
		strcat( comm, ":" );
		
		if( path != NULL )
		{
			strcat( comm, path ); 
		}
		
		if( s != NULL )
		{
			SpecialData *sd = (SpecialData *)s->f_SpecialData;
	
			char command[ 1024 ];	// maybe we should count that...
		
			sprintf( command, "php \"modules/system/module.php\" \"type=%s&module=files&args=false&command=directory&authkey=false&sessionid=%s&path=%s&subPath=\";",
				sd->type, s->f_SessionID, comm//path
			);
		
			int answerLength;
			BufString *bs  = NULL;
			ListString *result = PHPCall( command, &answerLength );
			if( result != NULL )
			{
				bs =BufStringNewSize( result->ls_Size );
				if( bs != NULL )
				{
					BufStringAddSize( bs, result->ls_Data, result->ls_Size );
				}
				ListStringDelete( result );
			}
		
			// we should parse result to get information about success
	
			free( comm );
			return bs;
		}
		
		free( comm );
	}
	return NULL;
}
コード例 #3
0
ファイル: fsysphp.c プロジェクト: seem8/friendup
BufString *Dir( File *s, const char *path )
{
	if( s != NULL )
	{
		SpecialData *sd = (SpecialData *)s->f_SpecialData;
	
		char command[ 1024 ];	// maybe we should count that...
		
		sprintf( command, "php \"modules/system/module.php\" \"type=%s&module=files&args=false&command=directory&authkey=false&sessionid=%s&path=%s&subPath=\";",
			sd->type, s->f_SessionID, path
		);
		
		int answerLength;
		ListString *result = PHPCall( command, &answerLength );
		BufString *bs =BufStringNewSize( result->ls_Size );
		BufStringAddSize( bs, result->ls_Data, result->ls_Size );
		ListStringDelete( result );
		
		// we should parse result to get information about success
	
		return bs;
	}
	return NULL;
}