Show More
@@ -1,73 +1,74 b'' | |||
|
1 | 1 | # -*- coding: utf-8 -*- |
|
2 | 2 | |
|
3 | 3 | # Copyright (C) 2010-2019 RhodeCode GmbH |
|
4 | 4 | # |
|
5 | 5 | # This program is free software: you can redistribute it and/or modify |
|
6 | 6 | # it under the terms of the GNU Affero General Public License, version 3 |
|
7 | 7 | # (only), as published by the Free Software Foundation. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU Affero General Public License |
|
15 | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 | 16 | # |
|
17 | 17 | # This program is dual-licensed. If you wish to learn more about the |
|
18 | 18 | # RhodeCode Enterprise Edition, including its added features, Support services, |
|
19 | 19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
20 | 20 | |
|
21 | 21 | import timeit |
|
22 | 22 | import logging |
|
23 | 23 | import click |
|
24 | 24 | |
|
25 | 25 | log = logging.getLogger(__name__) |
|
26 | 26 | |
|
27 | 27 | |
|
28 | 28 | @click.command() |
|
29 | 29 | @click.option('--server', help='Server url to connect to. e.g http://rc.local.com', required=True) |
|
30 | 30 | @click.option('--pages', help='load pages to visit from a file', required=True, type=click.File()) |
|
31 | 31 | @click.option('--repeat', help='number of times to repeat', default=10, type=int) |
|
32 | def main(server, repeat, pages): | |
|
32 | @click.option('--timeout', help='call timeout', default=60, type=int) | |
|
33 | def main(server, repeat, pages, timeout): | |
|
33 | 34 | |
|
34 | 35 | print("Repeating each URL %d times\n" % repeat) |
|
35 | 36 | pages = pages.readlines() |
|
36 | 37 | |
|
37 | 38 | for page_url in pages: |
|
38 | 39 | |
|
39 | 40 | url = "%s/%s" % (server, page_url.strip()) |
|
40 | 41 | print(url) |
|
41 | 42 | |
|
42 |
stmt = "requests.get(' |
|
|
43 | stmt = "requests.get('{}', timeout={})".format(url, timeout) | |
|
43 | 44 | t = timeit.Timer(stmt=stmt, setup="import requests") |
|
44 | 45 | |
|
45 | 46 | result = t.repeat(repeat=repeat, number=1) |
|
46 | 47 | print(" %.4f (min) - %.4f (max) - %.4f (avg)\n" % |
|
47 | 48 | (min(result), max(result), sum(result) / len(result))) |
|
48 | 49 | |
|
49 | 50 | |
|
50 | 51 | if __name__ == '__main__': |
|
51 | 52 | main() |
|
52 | 53 | |
|
53 | 54 | |
|
54 | 55 | |
|
55 | 56 | |
|
56 | 57 | |
|
57 | 58 | |
|
58 | 59 | |
|
59 | 60 | |
|
60 | 61 | |
|
61 | 62 | |
|
62 | 63 | |
|
63 | 64 | |
|
64 | 65 | |
|
65 | 66 | |
|
66 | 67 | |
|
67 | 68 | |
|
68 | 69 | |
|
69 | 70 | |
|
70 | 71 | |
|
71 | 72 | |
|
72 | 73 | |
|
73 | 74 |
General Comments 0
You need to be logged in to leave comments.
Login now