… | |
… | |
66 | |
66 | |
67 | Of course, if you want lots of policy (this can arguably be somewhat |
67 | Of course, if you want lots of policy (this can arguably be somewhat |
68 | useful) and you want to force your users to use the one and only event |
68 | useful) and you want to force your users to use the one and only event |
69 | model, you should I<not> use this module. |
69 | model, you should I<not> use this module. |
70 | |
70 | |
|
|
71 | #TODO# |
|
|
72 | |
|
|
73 | Net::IRC3 |
|
|
74 | AnyEvent::HTTPD |
|
|
75 | AnyEvent::DNS |
|
|
76 | IO::AnyEvent |
|
|
77 | Net::FPing |
|
|
78 | Net::XMPP2 |
|
|
79 | Coro |
|
|
80 | |
|
|
81 | AnyEvent::IRC |
|
|
82 | AnyEvent::HTTPD |
|
|
83 | AnyEvent::DNS |
|
|
84 | AnyEvent::Handle |
|
|
85 | AnyEvent::Socket |
|
|
86 | AnyEvent::FPing |
|
|
87 | AnyEvent::XMPP |
|
|
88 | AnyEvent::SNMP |
|
|
89 | Coro |
71 | |
90 | |
72 | =head1 DESCRIPTION |
91 | =head1 DESCRIPTION |
73 | |
92 | |
74 | L<AnyEvent> provides an identical interface to multiple event loops. This |
93 | L<AnyEvent> provides an identical interface to multiple event loops. This |
75 | allows module authors to utilise an event loop without forcing module |
94 | allows module authors to utilise an event loop without forcing module |
… | |
… | |
944 | EV/EV 400000 244 0.56 0.46 0.31 EV native interface |
963 | EV/EV 400000 244 0.56 0.46 0.31 EV native interface |
945 | EV/Any 100000 244 2.50 0.46 0.29 EV + AnyEvent watchers |
964 | EV/Any 100000 244 2.50 0.46 0.29 EV + AnyEvent watchers |
946 | CoroEV/Any 100000 244 2.49 0.44 0.29 coroutines + Coro::Signal |
965 | CoroEV/Any 100000 244 2.49 0.44 0.29 coroutines + Coro::Signal |
947 | Perl/Any 100000 513 4.92 0.87 1.12 pure perl implementation |
966 | Perl/Any 100000 513 4.92 0.87 1.12 pure perl implementation |
948 | Event/Event 16000 516 31.88 31.30 0.85 Event native interface |
967 | Event/Event 16000 516 31.88 31.30 0.85 Event native interface |
949 | Event/Any 16000 936 39.17 33.63 1.43 Event + AnyEvent watchers |
968 | Event/Any 16000 590 35.75 31.42 1.08 Event + AnyEvent watchers |
950 | Glib/Any 16000 1357 98.22 12.41 54.00 quadratic behaviour |
969 | Glib/Any 16000 1357 98.22 12.41 54.00 quadratic behaviour |
951 | Tk/Any 2000 1860 26.97 67.98 14.00 SEGV with >> 2000 watchers |
970 | Tk/Any 2000 1860 26.97 67.98 14.00 SEGV with >> 2000 watchers |
952 | POE/Event 2000 6644 108.64 736.02 14.73 via POE::Loop::Event |
971 | POE/Event 2000 6644 108.64 736.02 14.73 via POE::Loop::Event |
953 | POE/Select 2000 6343 94.13 809.12 565.96 via POE::Loop::Select |
972 | POE/Select 2000 6343 94.13 809.12 565.96 via POE::Loop::Select |
954 | |
973 | |
… | |
… | |
963 | |
982 | |
964 | Also, note that the number of watchers usually has a nonlinear effect on |
983 | Also, note that the number of watchers usually has a nonlinear effect on |
965 | overall speed, that is, creating twice as many watchers doesn't take twice |
984 | overall speed, that is, creating twice as many watchers doesn't take twice |
966 | the time - usually it takes longer. This puts event loops tested with a |
985 | the time - usually it takes longer. This puts event loops tested with a |
967 | higher number of watchers at a disadvantage. |
986 | higher number of watchers at a disadvantage. |
|
|
987 | |
|
|
988 | To put the range of results into perspective, consider that on the |
|
|
989 | benchmark machine, handling an event takes roughly 1600 CPU cycles with |
|
|
990 | EV, 3100 CPU cycles with AnyEvent's pure perl loop and almost 3000000 CPU |
|
|
991 | cycles with POE. |
968 | |
992 | |
969 | C<EV> is the sole leader regarding speed and memory use, which are both |
993 | C<EV> is the sole leader regarding speed and memory use, which are both |
970 | maximal/minimal, respectively. Even when going through AnyEvent, it uses |
994 | maximal/minimal, respectively. Even when going through AnyEvent, it uses |
971 | far less memory than any other event loop and is still faster than Event |
995 | far less memory than any other event loop and is still faster than Event |
972 | natively. |
996 | natively. |
… | |
… | |
1062 | |
1086 | |
1063 | =head3 Results |
1087 | =head3 Results |
1064 | |
1088 | |
1065 | name sockets create request |
1089 | name sockets create request |
1066 | EV 20000 69.01 11.16 |
1090 | EV 20000 69.01 11.16 |
1067 | Perl 20000 75.28 112.76 |
1091 | Perl 20000 73.32 35.87 |
1068 | Event 20000 212.62 257.32 |
1092 | Event 20000 212.62 257.32 |
1069 | Glib 20000 651.16 1896.30 |
1093 | Glib 20000 651.16 1896.30 |
1070 | POE 20000 349.67 12317.24 uses POE::Loop::Event |
1094 | POE 20000 349.67 12317.24 uses POE::Loop::Event |
1071 | |
1095 | |
1072 | =head3 Discussion |
1096 | =head3 Discussion |
… | |
… | |
1118 | |
1142 | |
1119 | =head3 Results |
1143 | =head3 Results |
1120 | |
1144 | |
1121 | name sockets create request |
1145 | name sockets create request |
1122 | EV 16 20.00 6.54 |
1146 | EV 16 20.00 6.54 |
|
|
1147 | Perl 16 25.75 12.62 |
1123 | Event 16 81.27 35.86 |
1148 | Event 16 81.27 35.86 |
1124 | Glib 16 32.63 15.48 |
1149 | Glib 16 32.63 15.48 |
1125 | Perl 16 24.62 162.37 |
|
|
1126 | POE 16 261.87 276.28 uses POE::Loop::Event |
1150 | POE 16 261.87 276.28 uses POE::Loop::Event |
1127 | |
1151 | |
1128 | =head3 Discussion |
1152 | =head3 Discussion |
1129 | |
1153 | |
1130 | The benchmark tries to test the performance of a typical small |
1154 | The benchmark tries to test the performance of a typical small |
1131 | server. While knowing how various event loops perform is interesting, keep |
1155 | server. While knowing how various event loops perform is interesting, keep |
1132 | in mind that their overhead in this case is usually not as important, due |
1156 | in mind that their overhead in this case is usually not as important, due |
1133 | to the small absolute number of watchers. |
1157 | to the small absolute number of watchers (that is, you need efficiency and |
|
|
1158 | speed most when you have lots of watchers, not when you only have a few of |
|
|
1159 | them). |
1134 | |
1160 | |
1135 | EV is again fastest. |
1161 | EV is again fastest. |
1136 | |
1162 | |
1137 | The C-based event loops Event and Glib come in second this time, as the |
1163 | The C-based event loops Event and Glib come in second this time, as the |
1138 | overhead of running an iteration is much smaller in C than in Perl (little |
1164 | overhead of running an iteration is much smaller in C than in Perl (little |
1139 | code to execute in the inner loop, and perl's function calling overhead is |
1165 | code to execute in the inner loop, and perl's function calling overhead is |
1140 | high, and updating all the data structures is costly). |
1166 | high, and updating all the data structures is costly). |
1141 | |
1167 | |
1142 | The pure perl event loop is much slower, but still competitive. |
1168 | The pure perl event loop is much slower, but still competitive. |
1143 | |
1169 | |
1144 | POE also performs much better in this case, but is is stillf ar behind the |
1170 | POE also performs much better in this case, but is is still far behind the |
1145 | others. |
1171 | others. |
1146 | |
1172 | |
1147 | =head3 Summary |
1173 | =head3 Summary |
1148 | |
1174 | |
1149 | =over 4 |
1175 | =over 4 |