Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Commit 9334b13

Browse files
committed
examples/example_time_calls.py - just a simple timer
1 parent bd220aa commit 9334b13

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

‎examples/example_time_calls.py‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env python
2+
"""Cloudflare API code - example"""
3+
4+
import os
5+
import sys
6+
import time
7+
8+
sys.path.insert(0, os.path.abspath('.'))
9+
sys.path.insert(0, os.path.abspath('..'))
10+
import CloudFlare
11+
12+
def main():
13+
"""Cloudflare API code - example"""
14+
15+
# Simple timing of calls
16+
17+
print('Create')
18+
tic = time.process_time_ns()
19+
cf = CloudFlare.CloudFlare()
20+
toc = time.process_time_ns()
21+
print('\t%7.3f ms' % ((toc-tic)/1000000.0))
22+
print('')
23+
24+
print('Call')
25+
for ii in range(0,10):
26+
tic = time.process_time_ns()
27+
r = cf.ips()
28+
toc = time.process_time_ns()
29+
print('\t%7.3f ms' % ((toc-tic)/1000000.0))
30+
print('')
31+
32+
print('Close')
33+
tic = time.process_time_ns()
34+
del cf
35+
toc = time.process_time_ns()
36+
print('\t%7.3f ms' % ((toc-tic)/1000000.0))
37+
print('')
38+
39+
if __name__ == '__main__':
40+
main()
41+

0 commit comments

Comments
 (0)