Matteo Scandolo | d2044a4 | 2017-08-07 16:08:28 -0700 | [diff] [blame] | 1 | # Copyright 2017-present Open Networking Foundation |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
Zack Williams | 045b63d | 2019-01-22 16:30:57 -0700 | [diff] [blame] | 15 | from __future__ import print_function |
| 16 | from xosapi import xos_grpc_client |
| 17 | import sys |
| 18 | import time |
Matteo Scandolo | d2044a4 | 2017-08-07 16:08:28 -0700 | [diff] [blame] | 19 | |
Scott Baker | 1677821 | 2017-05-04 14:35:00 -0700 | [diff] [blame] | 20 | """ nopper |
| 21 | |
| 22 | Sends NoOp operations to Core API Server at maximum rate and reports |
| 23 | performance. |
| 24 | """ |
| 25 | |
Scott Baker | 1677821 | 2017-05-04 14:35:00 -0700 | [diff] [blame] | 26 | sys.path.append("..") |
| 27 | |
Scott Baker | 1677821 | 2017-05-04 14:35:00 -0700 | [diff] [blame] | 28 | |
| 29 | def test_callback(): |
Zack Williams | 045b63d | 2019-01-22 16:30:57 -0700 | [diff] [blame] | 30 | print("TEST: nop") |
Scott Baker | 1677821 | 2017-05-04 14:35:00 -0700 | [diff] [blame] | 31 | |
| 32 | c = xos_grpc_client.coreclient |
| 33 | |
| 34 | while True: |
| 35 | tStart = time.time() |
| 36 | count = 0 |
| 37 | while True: |
Zack Williams | 045b63d | 2019-01-22 16:30:57 -0700 | [diff] [blame] | 38 | if isinstance(xos_grpc_client.coreclient, xos_grpc_client.SecureClient): |
| 39 | c.utility.AuthenticatedNoOp(xos_grpc_client.Empty()) |
Scott Baker | 1677821 | 2017-05-04 14:35:00 -0700 | [diff] [blame] | 40 | else: |
Zack Williams | 045b63d | 2019-01-22 16:30:57 -0700 | [diff] [blame] | 41 | c.utility.NoOp(xos_grpc_client.Empty()) |
Scott Baker | 1677821 | 2017-05-04 14:35:00 -0700 | [diff] [blame] | 42 | count = count + 1 |
Zack Williams | 045b63d | 2019-01-22 16:30:57 -0700 | [diff] [blame] | 43 | elap = time.time() - tStart |
| 44 | if elap >= 10: |
| 45 | print("nops/second = %d" % int(count / elap)) |
Scott Baker | 1677821 | 2017-05-04 14:35:00 -0700 | [diff] [blame] | 46 | tStart = time.time() |
| 47 | count = 0 |
| 48 | |
Scott Baker | 1677821 | 2017-05-04 14:35:00 -0700 | [diff] [blame] | 49 | |
Zack Williams | 045b63d | 2019-01-22 16:30:57 -0700 | [diff] [blame] | 50 | xos_grpc_client.start_api_parseargs(test_callback) |