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 97 98 99 100 101 102 103 104 105
|
//-----------------------------------------------------------------------------
//
// 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 <SDL.h>
#include <stdlib.h>
#ifdef _WIN32
#pragma comment(lib, "sdl.lib")
#pragma comment(lib, "sdlmain.lib")
#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);
if (SDL_Init(SDL_INIT_TIMER) < 0) {
fprintf(stderr, "Couldn't load SDL: %s\n", SDL_GetError());
return 3;
}
atexit(SDL_Quit);
last_elapsed = cur_elapsed = SDL_GetTicks();
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 = SDL_GetTicks();
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 = SDL_GetTicks();
for (i = 0; i < 10; i++) {
ilLoadImage(argv[1]);
cur_elapsed = SDL_GetTicks();
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;
}
|