Skip to content

Commit bfc6af8

Browse files
committed
add init check
1 parent 55dcafe commit bfc6af8

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

.github/workflows/python-perf.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,13 @@ jobs:
4141
os: [ubuntu-latest, windows-latest, macos-latest]
4242
include:
4343
- os: ubuntu-latest
44+
init_performance_threshold_sec: 0.001
4445
performance_threshold_sec: 0.006
4546
- os: windows-latest
47+
init_performance_threshold_sec: 0.001
4648
performance_threshold_sec: 0.006
4749
- os: macos-latest
50+
init_performance_threshold_sec: 0.001
4851
performance_threshold_sec: 0.006
4952

5053
steps:
@@ -62,7 +65,7 @@ jobs:
6265
run: pip install -r requirements.txt
6366

6467
- name: Test
65-
run: python test_cobra_perf.py ${{secrets.PV_VALID_ACCESS_KEY}} 100 ${{matrix.performance_threshold_sec}}
68+
run: python test_cobra_perf.py ${{secrets.PV_VALID_ACCESS_KEY}} 100 ${{matrix.performance_threshold_sec}} ${{matrix.init_performance_threshold_sec}}
6669

6770
perf-self-hosted:
6871
runs-on: ${{ matrix.machine }}

binding/python/test_cobra_perf.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,24 @@ class CobraPerformanceTestCase(unittest.TestCase):
2222
ACCESS_KEY = sys.argv[1]
2323
NUM_TEST_ITERATIONS = int(sys.argv[2])
2424
PERFORMANCE_THRESHOLD_SEC = float(sys.argv[3])
25+
INIT_THRESHOLD_SEC = float(sys.argv.get(4, 0.005))
2526

2627
def test_performance(self):
28+
init_results = []
29+
for i in range(self.NUM_TEST_ITERATIONS):
30+
start = time()
31+
c = Cobra(access_key=sys.argv[1], library_path=pv_library_path('../..'))
32+
init_time = time.time() - start
33+
34+
c.delete()
35+
36+
if i > 0:
37+
init_results.append(init_time)
38+
39+
avg_init = sum(init_results) / self.NUM_TEST_ITERATIONS
40+
print("Average init: %s" % avg_init)
41+
self.assertLess(avg_init, self.INIT_THRESHOLD_SEC)
42+
2743
cobra = Cobra(access_key=sys.argv[1], library_path=pv_library_path('../..'))
2844
audio = read_wav_file(
2945
os.path.join(os.path.dirname(__file__), '../../res/audio/sample.wav'),

0 commit comments

Comments
 (0)