rcaputo/reflex — pull request #4 by triddle (2012-08-18 22:01:25+00:00)
Title: Created benchmark suite for event delivery and consumption

The suite has 7 benchmarks that measures the performance of not only event creation but also event consumption. One of the benchmarks is a simple event dispatcher that manages callbacks with weak references - this is how I envision working with non-OO aware pure callback style APIs such as AnyEvent.

Here's some sample output from my machine:

$ ./bench.pl
Configuration: 500000 events and 60 seconds minimum test time
Loading benchmarks from bench/... found 7 files
loading bench/method-array.pl... done
loading bench/method-hash.pl... done
loading bench/objectmethod-array.pm... done
loading bench/objectmethod-cbmanager.pm... done
loading bench/objectmethod-hash.pm... done
loading bench/reflex-watches+no_event_methods.pm... done
loading bench/reflex-watches.pm... done
Generating test data... done
Measuring bench/method-array.pl... 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 done
Measuring bench/method-hash.pl... 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 done
Measuring bench/objectmethod-array.pm... 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 done
Measuring bench/objectmethod-cbmanager.pm... 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 done
Measuring bench/objectmethod-hash.pm... 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 done
Measuring bench/reflex-watches+no_event_methods.pm... 1 done
Measuring bench/reflex-watches.pm... 1 done
Report format: file events per second cost of solution
bench/method-array.pl 801392 1
bench/objectmethod-array.pm 717160 1.11745217245803
bench/method-hash.pl 481298 1.66506405594871
bench/objectmethod-hash.pm 433866 1.8470956470431
bench/objectmethod-cbmanager.pm 135025 5.935137937419
bench/reflex-watches.pm 12757 62.8197852159599
bench/reflex-watches+no_event_methods.pm 12648 63.3611638203669