Skip to content

Commit 00afd22

Browse files
add a timing wrapper around model serialization
Signed-off-by: Spencer Schrock <[email protected]>
1 parent 8ff5fb7 commit 00afd22

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

benchmarks/time_serialize.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Copyright 2025 The Sigstore Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
16+
"""Script for timing model serialization benchmarks."""
17+
18+
import argparse
19+
import time
20+
21+
import serialize
22+
23+
24+
def build_parser() -> argparse.ArgumentParser:
25+
"""Builds the command line parser to benchmark serializing models."""
26+
parser = argparse.ArgumentParser(description="model benchmark data")
27+
28+
parser.add_argument("path", help="path to model")
29+
30+
parser.add_argument(
31+
"--repeat",
32+
help="how many times to repeat each model",
33+
type=int,
34+
default=6,
35+
)
36+
37+
return parser
38+
39+
40+
if __name__ == "__main__":
41+
paper_args = build_parser().parse_args()
42+
43+
args = serialize.build_parser().parse_args(
44+
[paper_args.path, "--use_shards"]
45+
)
46+
47+
print(paper_args.path)
48+
for _ in range(paper_args.repeat):
49+
st = time.time()
50+
payload = serialize.run(args)
51+
en = time.time()
52+
hash = en - st
53+
54+
print(f"hash: {hash:0.4f}")

0 commit comments

Comments
 (0)