File: benchmark.c

package info (click to toggle)
devil 1.6.8-rc2-3%2Blenny1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 10,004 kB
  • ctags: 4,659
  • sloc: ansic: 37,357; sh: 13,641; cpp: 7,193; pascal: 792; makefile: 348; python: 47
file content (96 lines) | stat: -rw-r--r-- 1,997 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//-----------------------------------------------------------------------------
//
// ImageLib Benchmark Source
// Copyright (C) 2000 by Denton Woods
// Last modified:  08/21/2001 <--Y2K Compliant! =]
//
// Filename: testil/benchmark/benchmark.c
//
// Description:  Performs benchmarking of DevIL and ILU.
//					This requires the Simple DirectMedia Layer library,
//					available at http://www.libsdl.org
//
//-----------------------------------------------------------------------------


#include <IL/il.h>
#include <IL/ilu.h>
#include <stdlib.h>
#include <time.h>


#ifdef _WIN32
	#ifdef  _DEBUG
		#pragma comment(linker, "/NODEFAULTLIB:msvcrt.lib")
	#endif//_DEBUG
#endif


int main(int argc, char **argv)
{
	ILuint		id, Error;
	ILuint		i;
	ILdouble	avgtime, curtime, last_elapsed, cur_elapsed;

	if (argc < 2) {
		printf("Please specify a filename.\n");
		return 1;
	}

	if (ilGetInteger(IL_VERSION_NUM) < IL_VERSION ||
		ilGetInteger(ILU_VERSION_NUM) < ILU_VERSION) {
		printf("DevIL version is different...exiting!\n");
		return 2;
	}

	ilInit();


	ilGenImages(1, &id);
	ilBindImage(id);

	last_elapsed = cur_elapsed = time(NULL);

	
	ilHint(IL_MEM_SPEED_HINT, IL_FASTEST);
	printf("Using IL_FASTEST\n");
	avgtime = 0.0;

	for (i = 0; i < 10; i++) {
		ilLoadImage(argv[1]);
		cur_elapsed = time(NULL);
		curtime = cur_elapsed - last_elapsed;
		last_elapsed = cur_elapsed;
		avgtime += curtime;
		printf("%g\n", curtime);
	}
	
	printf("Average time:  %g\n", avgtime / 10.0);


	ilHint(IL_MEM_SPEED_HINT, IL_LESS_MEM);
	printf("Using IL_LESS_MEM\n");
	avgtime = 0.0;


	last_elapsed = cur_elapsed = time(NULL);

	for (i = 0; i < 10; i++) {
		ilLoadImage(argv[1]);
		cur_elapsed = time(NULL);
		curtime = cur_elapsed - last_elapsed;
		last_elapsed = cur_elapsed;
		avgtime += curtime;
		printf("%g\n", curtime);
	}
	printf("Average time:  %g\n", avgtime / 10.0);


	ilDeleteImages(1, &id);

	while ((Error = ilGetError())) {
		printf("Error: %s\n", iluErrorString(Error));
	}

	return 0;
}