Skip to content

Commit

Permalink
add init check
Browse files Browse the repository at this point in the history
  • Loading branch information
albho committed Feb 1, 2024
1 parent 55dcafe commit bfc6af8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .github/workflows/python-perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,13 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest]
include:
- os: ubuntu-latest
init_performance_threshold_sec: 0.001
performance_threshold_sec: 0.006
- os: windows-latest
init_performance_threshold_sec: 0.001
performance_threshold_sec: 0.006
- os: macos-latest
init_performance_threshold_sec: 0.001
performance_threshold_sec: 0.006

steps:
Expand All @@ -62,7 +65,7 @@ jobs:
run: pip install -r requirements.txt

- name: Test
run: python test_cobra_perf.py ${{secrets.PV_VALID_ACCESS_KEY}} 100 ${{matrix.performance_threshold_sec}}
run: python test_cobra_perf.py ${{secrets.PV_VALID_ACCESS_KEY}} 100 ${{matrix.performance_threshold_sec}} ${{matrix.init_performance_threshold_sec}}

perf-self-hosted:
runs-on: ${{ matrix.machine }}
Expand Down
16 changes: 16 additions & 0 deletions binding/python/test_cobra_perf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,24 @@ class CobraPerformanceTestCase(unittest.TestCase):
ACCESS_KEY = sys.argv[1]
NUM_TEST_ITERATIONS = int(sys.argv[2])
PERFORMANCE_THRESHOLD_SEC = float(sys.argv[3])
INIT_THRESHOLD_SEC = float(sys.argv.get(4, 0.005))

def test_performance(self):
init_results = []
for i in range(self.NUM_TEST_ITERATIONS):
start = time()
c = Cobra(access_key=sys.argv[1], library_path=pv_library_path('../..'))
init_time = time.time() - start

c.delete()

if i > 0:
init_results.append(init_time)

avg_init = sum(init_results) / self.NUM_TEST_ITERATIONS
print("Average init: %s" % avg_init)
self.assertLess(avg_init, self.INIT_THRESHOLD_SEC)

cobra = Cobra(access_key=sys.argv[1], library_path=pv_library_path('../..'))
audio = read_wav_file(
os.path.join(os.path.dirname(__file__), '../../res/audio/sample.wav'),
Expand Down

0 comments on commit bfc6af8

Please sign in to comment.