def test_get_default_energy_values_with_pkg_dram_rapl_api_two_sockets(fs_pkg_dram_two_socket): device = RaplDevice() device.configure() assert device.get_energy() == [fs_pkg_dram_two_socket.domains_current_energy['package_0'], fs_pkg_dram_two_socket.domains_current_energy['package_1'], fs_pkg_dram_two_socket.domains_current_energy['dram_0'], fs_pkg_dram_two_socket.domains_current_energy['dram_1']]
def test_measure_rapl_device_all_domains(_mocked_perf_counter, fs_pkg_dram_one_socket, one_gpu_api): domains = [RaplPackageDomain(0), RaplDramDomain(0), NvidiaGPUDomain(0)] correct_trace = CorrectTrace(domains, [fs_pkg_dram_one_socket, one_gpu_api], TIMESTAMP_TRACE) # test rapl = RaplDevice() rapl.configure(domains=[RaplPackageDomain(0), RaplDramDomain(0)]) nvidia = NvidiaGPUDevice() nvidia.configure(domains=[NvidiaGPUDomain(0)]) meter = EnergyMeter([rapl, nvidia]) correct_trace.add_new_sample('foo') # test meter.start(tag="foo") correct_trace.add_new_sample('bar') # test meter.record(tag="bar") correct_trace.add_new_sample('') # test meter.stop() for sample1, sample2 in zip(correct_trace, meter): # test assert_sample_are_equals(sample1, sample2) # test
def test_get_dram_energy_with_pkg_dram_rapl_api_return_correct_value(fs_pkg_dram_one_socket): """ Create a RaplDevice instance on a machine with package and dram rapl api with on one socket configure it to monitor dram domain use the `get_energy` method and check if: - the returned list contains one element - this element is the power consumption of the dram on socket 0 """ device = RaplDevice() device.configure([RaplDramDomain(0)]) assert device.get_energy() == [fs_pkg_dram_one_socket.domains_current_energy['dram_0']]
def test_get_package0_and_all_dram_energy_with_pkg_dram_rapl_api_two_sockets_return_correct_value(fs_pkg_dram_two_socket): """ Create a RaplDevice instance on a machine with package and dram rapl api with on two socket configure it to monitor package domains on socket 0 and dram domains on socket 0 and 1 use the `get_energy` method and check if: - the returned list contains 3 elements - these elements are the power consumption of the package on socket 0 and dram on socket 0 and socket 1 """ device = RaplDevice() device.configure([RaplPackageDomain(0), RaplDramDomain(0), RaplDramDomain(1)]) assert device.get_energy() == [fs_pkg_dram_two_socket.domains_current_energy['package_0'], fs_pkg_dram_two_socket.domains_current_energy['dram_0'], fs_pkg_dram_two_socket.domains_current_energy['dram_1']]
def test_configure_device_to_get_pkg_energy_on_cpu1_with_no_cpu1_raise_NoSuchDomainError(fs_pkg_dram_one_socket): device = RaplDevice() with pytest.raises(NoSuchDomainError): device.configure([RaplPackageDomain(1)])
def test_configure_device_to_get_dram_energy_with_no_rapl_dram_api_raise_NoSuchDomainError(fs_pkg_one_socket): device = RaplDevice() with pytest.raises(NoSuchDomainError): device.configure([RaplDramDomain(0)])
def test_create_RaplDevice(fs_pkg_one_socket): device = RaplDevice() assert device is not None assert isinstance(device, RaplDevice)
def test_create_RaplDevice_with_no_rapl_api_raise_NoSuchEnergyDeviceError(empty_fs): with pytest.raises(NoSuchEnergyDeviceError): RaplDevice()
def test_get_default_energy_values_with_pkg_rapl_api(fs_pkg_one_socket): device = RaplDevice() device.configure() assert device.get_energy() == [fs_pkg_one_socket.domains_current_energy['package_0']]
def test_get_configured_domains_with_pkg_values_on_pkg_dram_rapl_api_return_correct_values(fs_pkg_dram_one_socket): configured_domains = [RaplPackageDomain(0)] device = RaplDevice() device.configure(configured_domains) assert configured_domains == device.get_configured_domains()
def test_get_configured_domains_on_non_configured_device_raise_NotConfiguredDeviceException(fs_pkg_dram_one_socket): device = RaplDevice() with pytest.raises(NotConfiguredDeviceException): device.get_configured_domains()