On Jan 9, 2007, at 3:14 PM, Michael Niedermayer wrote: > On Tue, Jan 09, 2007 at 02:13:51PM -0600, Ryan Martell wrote: >> On Jan 8, 2007, at 8:24 PM, Michael Niedermayer wrote: >>> On Mon, Jan 08, 2007 at 11:56:24AM -0600, Ryan Martell wrote: >>> [...] > [...] >> #ifdef DEBUG >> void av_benchmark_random(void) >> { >> int i; >> AVRandomState state; >> >> av_init_random(0xdeadbeef, &state); >> >> av_log(NULL, AV_LOG_ERROR, "1000 outputs of av_random()\n"); >> { >> START_TIMER; >> for (i = 0; i < 1000; i++) { >> av_random(&state); >> } >> STOP_TIMER("1000 calls of av_random"); > > this should rather be > int x=0; > for (j = 0; j < 100; j++) { > START_TIMER; > x+= av_random(&state); > STOP_TIMER("first call to av_random"); > for (i = 1; i < AV_RANDOM_N; i++) { > START_TIMER; > x+= av_random(&state); > STOP_TIMER("AV_RANDOM_N calls of av_random"); > } > } > av_log(NULL, AV_LOG_ERROR, "final value:%X\n", x); > > without the x, the compiler can simply optimize the whole av_random > () out > (gcc of course is too stupid to do this but still it might remove a > few > operations at random) > > and spliting the quick and slow cases provides more information, also > *_TIMER is designed for code which is approxiately equally fast on > each > run and thats where it provides the best accuracy ... > > printing the final value gives some regression test (a simple if > (x==expected) > ould be fine too, the thing that is important is that x is used > otherwise > a compiler could remove x and the whole av_random()) Gotcha. > except that the code looks good ... Okay, changed (and attached). For the record, the timing units I sent before were only timing the generate_untempered function, since it's only called every AV_RANDOM_N times av_random is called. Final question: typically, I use time(NULL) to initialize the seeds of a random number generator. Since ffmpeg says don't use time (NULL), what's the best pseodo-random seed generator to use? -------------- next part -------------- A non-text attachment was scrubbed... Name: random.c Type: application/octet-stream Size: 3516 bytes Desc: not available URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070109/ff390857/attachment.obj> -------------- next part -------------- A non-text attachment was scrubbed... Name: random.h Type: application/octet-stream Size: 2408 bytes Desc: not available URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070109/ff390857/attachment-0001.obj>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4