Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use KiB and MiB as units instead of kB and MB. #199

Merged
merged 2 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyperf/_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ def format_filesize(size):
return '%.0f byte' % size

if size > 10 * 1024 * 1024:
return '%.1f MB' % (size / (1024.0 * 1024.0))
return '%.1f MiB' % (size / (1024.0 * 1024.0))

return '%.1f kB' % (size / 1024.0)
return '%.1f kiB' % (size / 1024.0)


def format_filesizes(sizes):
Expand Down
6 changes: 3 additions & 3 deletions pyperf/tests/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class CpuFunctionsTests(unittest.TestCase):
stepping\t: 9
microcode\t: 0x1c
cpu MHz\t\t: 1287.554
cache size\t: 4096 KB
cache size\t: 4096 KiB
physical id\t: 0
siblings\t: 4
core id\t\t: 0
Expand All @@ -82,7 +82,7 @@ class CpuFunctionsTests(unittest.TestCase):
stepping\t: 9
microcode\t: 0x1c
cpu MHz\t\t: 1225.363
cache size\t: 4096 KB
cache size\t: 4096 KiB
physical id\t: 0
siblings\t: 4
core id\t\t: 0
Expand All @@ -109,7 +109,7 @@ class CpuFunctionsTests(unittest.TestCase):
stepping\t: 9
microcode\t: 0x1c
cpu MHz\t\t: 1200.101
cache size\t: 4096 KB
cache size\t: 4096 KiB
physical id\t: 0
siblings\t: 4
core id\t\t: 1
Expand Down
14 changes: 7 additions & 7 deletions pyperf/tests/test_perf_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,13 +556,13 @@ def test_dump(self):
def test_dump_track_memory(self):
expected = """
Run 1: calibrate the number of loops: 2^15
- calibrate 1: 7188.0 kB (loops: 2^15)
- calibrate 1: 7188.0 kiB (loops: 2^15)
Run 2: 0 warmups, 1 value, 2^15 loops
- value 1: 7188.0 kB
- value 1: 7188.0 kiB
Run 3: 0 warmups, 1 value, 2^15 loops
- value 1: 7192.0 kB
- value 1: 7192.0 kiB
Run 4: 0 warmups, 1 value, 2^15 loops
- value 1: 7208.0 kB
- value 1: 7208.0 kiB
"""
filename = os.path.join(TESTDIR, 'track_memory.json')
stdout = self.run_command('dump', filename)
Expand Down Expand Up @@ -595,7 +595,7 @@ def test_dump_verbose(self):
date: 2016-10-21 03:14:19.670631
duration: 338 ms
load_avg_1min: 0.29
mem_max_rss: 13.4 MB
mem_max_rss: 13.4 MiB
runnable_threads: 1
uptime: 2 day 2 hour 4 min
Run 2: 1 warmup, 3 values, 8 loops
Expand All @@ -609,7 +609,7 @@ def test_dump_verbose(self):
date: 2016-10-21 03:14:20.496710
duration: 723 ms
load_avg_1min: 0.29
mem_max_rss: 13.5 MB
mem_max_rss: 13.5 MiB
runnable_threads: 1
uptime: 2 day 2 hour 4 min
"""
Expand Down Expand Up @@ -689,7 +689,7 @@ def _check_track_memory(self, track_option):
'[1,2]*1000',
'-o', tmp_name)
bench = pyperf.Benchmark.load(tmp_name)

self._check_track_memory_bench(bench, loops=5)

def test_track_memory(self):
Expand Down
4 changes: 2 additions & 2 deletions pyperf/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ def test_format_filesize(self):
self.assertEqual(format_filesize(1),
'1 byte')
self.assertEqual(format_filesize(10 * 1024),
'10.0 kB')
'10.0 kiB')
self.assertEqual(format_filesize(12.4 * 1024 * 1024),
'12.4 MB')
'12.4 MiB')

def test_get_python_names(self):
self.assertEqual(utils.get_python_names('/usr/bin/python3.6',
Expand Down