| 1 |
""" |
| 2 |
Benchmarks for L{twisted.internet.task}. |
| 3 |
""" |
| 4 |
|
| 5 |
from timer import timeit |
| 6 |
|
| 7 |
from twisted.internet import task |
| 8 |
|
| 9 |
|
| 10 |
def test_performance(): |
| 11 |
""" |
| 12 |
L{LoopingCall} should not take long to skip a lot of iterations. |
| 13 |
""" |
| 14 |
clock = task.Clock() |
| 15 |
call = task.LoopingCall(lambda: None) |
| 16 |
call.clock = clock |
| 17 |
|
| 18 |
call.start(0.1) |
| 19 |
clock.advance(1000000) |
| 20 |
|
| 21 |
|
| 22 |
def main(): |
| 23 |
print("LoopingCall large advance takes", timeit(test_performance, iter=1)) |
| 24 |
|
| 25 |
|
| 26 |
if __name__ == "__main__": |
| 27 |
main() |