blob: ffb8b38c52fcaf500bff60ec3c5cf22dbbcab161 [file] [log] [blame]
Matteo Scandolod2044a42017-08-07 16:08:28 -07001# 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 Williams045b63d2019-01-22 16:30:57 -070015from __future__ import print_function
16from xosapi import xos_grpc_client
17import sys
18import time
Matteo Scandolod2044a42017-08-07 16:08:28 -070019
Scott Baker16778212017-05-04 14:35:00 -070020""" nopper
21
22 Sends NoOp operations to Core API Server at maximum rate and reports
23 performance.
24"""
25
Scott Baker16778212017-05-04 14:35:00 -070026sys.path.append("..")
27
Scott Baker16778212017-05-04 14:35:00 -070028
29def test_callback():
Zack Williams045b63d2019-01-22 16:30:57 -070030 print("TEST: nop")
Scott Baker16778212017-05-04 14:35:00 -070031
32 c = xos_grpc_client.coreclient
33
34 while True:
35 tStart = time.time()
36 count = 0
37 while True:
Zack Williams045b63d2019-01-22 16:30:57 -070038 if isinstance(xos_grpc_client.coreclient, xos_grpc_client.SecureClient):
39 c.utility.AuthenticatedNoOp(xos_grpc_client.Empty())
Scott Baker16778212017-05-04 14:35:00 -070040 else:
Zack Williams045b63d2019-01-22 16:30:57 -070041 c.utility.NoOp(xos_grpc_client.Empty())
Scott Baker16778212017-05-04 14:35:00 -070042 count = count + 1
Zack Williams045b63d2019-01-22 16:30:57 -070043 elap = time.time() - tStart
44 if elap >= 10:
45 print("nops/second = %d" % int(count / elap))
Scott Baker16778212017-05-04 14:35:00 -070046 tStart = time.time()
47 count = 0
48
Scott Baker16778212017-05-04 14:35:00 -070049
Zack Williams045b63d2019-01-22 16:30:57 -070050xos_grpc_client.start_api_parseargs(test_callback)