Skip to content

Commit

Permalink
peakmem benchmark for zipstorage
Browse files Browse the repository at this point in the history
  • Loading branch information
luizirber committed Apr 5, 2022
1 parent b640fc7 commit 7b55c52
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
28 changes: 28 additions & 0 deletions benchmarks/benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,31 @@ def time_load_small_from_zipstorage(self):

def teardown(self):
self.zipfile.close()


class PeakmemZipStorageSuite:
def setup(self):
import zipfile
self.zipfile = NamedTemporaryFile()

with zipfile.ZipFile(self.zipfile, mode='w',
compression=zipfile.ZIP_STORED) as storage:
for i in range(100_000):
# just so we have lots of entries
storage.writestr(str(i), b"0")
# one big-ish entry
storage.writestr("sig1", b"9" * 1_000_000)


def peakmem_load_from_zipstorage(self):
with ZipStorage(self.zipfile.name) as storage:
for i in range(20):
storage.load("sig1")

def peakmem_load_small_from_zipstorage(self):
with ZipStorage(self.zipfile.name) as storage:
for i in range(20):
storage.load("99999")

def teardown(self):
self.zipfile.close()
2 changes: 1 addition & 1 deletion src/core/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ impl ZipStorage {
metadata_builder: |archive: &piz::ZipArchive| {
archive
.entries()
.into_iter()
.iter()
.map(|entry| (entry.path.as_os_str(), entry))
.collect()
},
Expand Down

0 comments on commit 7b55c52

Please sign in to comment.