IOhannes m zmoelnig wrote:
Claude Heiland-Allen wrote:
Hi all,
Just wondering why hsv2rgb.pd (which is pretty incomprehensible) isn't
a compiled external. I had to write a C implementation because the Pd
implementation was too slow. Some rough benchmarks:
CPU: 1.6GHz Pentium-M
Patch: rather complex, with 25*1024 calls to hsv2rgb per second.
CPU-load as reported by load-meter.pd:
hsv2rgb.pd : 108%
fast_hsv2rgb.c : 94%
nop.pd : 94%
Quite a difference.
honestly i think that the difference is way less than i would have
expected it.
The benchmark wasn't clean - the patch was doing a whole bunch of other
stuff at the same time. See revised benchmark above, and see below for
a clean benchmark:
hsv2rgb.pd : 26900 cputime (including test source) [1]
fast_hsv2rgb.c : 6730 cputime (including test source) [2]
no object : 5750 cputime (test source) [3]
([1]-[3]) / ([2]-[3]) gives 21.8
C is almost 22x (2200%) faster than the Pd implementation of hsv2rgb.
Claude
--
http://claudiusmaximus.goto10.org
#N canvas 0 0 614 541 10;
#X obj 181 14 bng 15 250 50 0 empty empty start 17 7 0 10 -262144 -1
-1;
#X obj 434 315 hsv2rgb;
#X obj 224 315 fast_hsv2rgb;
#X obj 224 291 pack f f f;
#X obj 223 162 t b b b;
#X obj 296 231 random 1000;
#X obj 296 255 / 1000;
#X obj 246 211 random 1000;
#X obj 246 235 / 1000;
#X obj 196 191 random 1000;
#X obj 196 215 / 1000;
#X obj 434 291 pack f f f;
#X obj 433 162 t b b b;
#X obj 506 231 random 1000;
#X obj 506 255 / 1000;
#X obj 456 211 random 1000;
#X obj 456 235 / 1000;
#X obj 406 191 random 1000;
#X obj 406 215 / 1000;
#X obj 201 83 t b b b;
#X obj 201 359 cputime;
#X floatatom 201 388 5 0 0 1 C - -;
#X obj 411 83 t b b b;
#X obj 411 359 cputime;
#X floatatom 411 388 5 0 0 1 Pd - -;
#X obj 223 135 until;
#X obj 433 135 until;
#X obj 180 43 t b b b;
#X obj 34 291 pack f f f;
#X obj 33 162 t b b b;
#X obj 106 231 random 1000;
#X obj 106 255 / 1000;
#X obj 56 211 random 1000;
#X obj 56 235 / 1000;
#X obj 6 191 random 1000;
#X obj 6 215 / 1000;
#X obj 11 83 t b b b;
#X obj 11 359 cputime;
#X floatatom 11 388 5 0 0 1 base - -;
#X obj 33 135 until;
#X obj 341 40 t f f f;
#X floatatom 341 22 5 0 0 1 iters - -;
#X obj 120 432 expr ($f3-$f1)/($f2-$f1);
#X floatatom 120 471 0 0 0 3 C_is_this_many_times_faster_than_Pd -
-;
#X msg 277 42 1e+07;
#X obj 433 109 f;
#X obj 223 107 f;
#X obj 33 107 f;
#X obj 276 22 loadbang;
#X connect 0 0 27 0;
#X connect 3 0 2 0;
#X connect 4 0 9 0;
#X connect 4 1 7 0;
#X connect 4 2 5 0;
#X connect 5 0 6 0;
#X connect 6 0 3 2;
#X connect 7 0 8 0;
#X connect 8 0 3 1;
#X connect 9 0 10 0;
#X connect 10 0 3 0;
#X connect 11 0 1 0;
#X connect 12 0 17 0;
#X connect 12 1 15 0;
#X connect 12 2 13 0;
#X connect 13 0 14 0;
#X connect 14 0 11 2;
#X connect 15 0 16 0;
#X connect 16 0 11 1;
#X connect 17 0 18 0;
#X connect 18 0 11 0;
#X connect 19 0 20 1;
#X connect 19 1 46 0;
#X connect 19 2 20 0;
#X connect 20 0 21 0;
#X connect 21 0 42 1;
#X connect 22 0 23 1;
#X connect 22 1 45 0;
#X connect 22 2 23 0;
#X connect 23 0 24 0;
#X connect 24 0 42 2;
#X connect 25 0 4 0;
#X connect 26 0 12 0;
#X connect 27 0 36 0;
#X connect 27 1 19 0;
#X connect 27 2 22 0;
#X connect 29 0 34 0;
#X connect 29 1 32 0;
#X connect 29 2 30 0;
#X connect 30 0 31 0;
#X connect 31 0 28 2;
#X connect 32 0 33 0;
#X connect 33 0 28 1;
#X connect 34 0 35 0;
#X connect 35 0 28 0;
#X connect 36 0 37 1;
#X connect 36 1 47 0;
#X connect 36 2 37 0;
#X connect 37 0 38 0;
#X connect 38 0 42 0;
#X connect 39 0 29 0;
#X connect 40 0 47 1;
#X connect 40 1 46 1;
#X connect 40 2 45 1;
#X connect 41 0 40 0;
#X connect 42 0 43 0;
#X connect 44 0 41 0;
#X connect 45 0 26 0;
#X connect 46 0 25 0;
#X connect 47 0 39 0;
#X connect 48 0 44 0;