MCPcopy Create free account
hub / github.com/mlco2/codecarbon / test_cpu_load_detection

Method test_cpu_load_detection

tests/test_cpu_load.py:52–69  ·  view source on GitHub ↗
(
        self,
        mocked_is_psutil_available,
        mocked_is_powergadget_available,
        mocked_is_rapl_available,
    )

Source from the content-addressed store, hash-verified

50 self.assertEqual(cpu.total_power().W, 50)
51
52 def test_cpu_load_detection(
53 self,
54 mocked_is_psutil_available,
55 mocked_is_powergadget_available,
56 mocked_is_rapl_available,
57 ):
58 tracker = OfflineEmissionsTracker(country_iso_code="FRA")
59 for hardware in tracker._hardware:
60 if (
61 isinstance(hardware, CPU) and hardware._mode == MODE_CPU_LOAD
62 ) or isinstance(hardware, AppleSiliconChip):
63 break
64 else:
65 raise Exception("No CPU load !!!")
66 tracker.start()
67 sleep(0.5)
68 emission = tracker.stop()
69 self.assertGreater(emission, 0.0)
70
71 def test_cpu_calculate_power_from_cpu_load_threadripper(
72 self,

Callers

nothing calls this directly

Calls 3

startMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected