Skip to content

Commit

Permalink
Adjust perf test to exit gracefully if perf not available
Browse files Browse the repository at this point in the history
  • Loading branch information
mp15 committed Oct 10, 2022
1 parent a7a073b commit 2e08f20
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tests/test_core_perf.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import time

import codecarbon.core.perf
import codecarbon.core.cpu

try:
from codecarbon.core.perf import Perf
except ImportError:
Perf = None


def test_perf():
x = codecarbon.core.perf.Perf(["energy-pkg"])
if codecarbon.core.cpu.is_perf_available() == False:
return
x = Perf(["energy-pkg"])
x.start()
time.sleep(20)
x.delta(20.0)
Expand Down

0 comments on commit 2e08f20

Please sign in to comment.