File: run_func

package info (click to toggle)
python-orjson 3.10.7-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,180 kB
  • sloc: ansic: 11,270; python: 6,658; sh: 135; makefile: 9
file content (27 lines) | stat: -rwxr-xr-x 538 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env python3
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

import sys
import lzma
import os
import gc

gc.disable()

os.sched_setaffinity(os.getpid(), {0, 1})

from orjson import dumps, loads

filename = sys.argv[1]
n = int(sys.argv[3]) if len(sys.argv) >= 4 else 1000

with lzma.open(filename, "r") as fileh:
    file_bytes = fileh.read()

if sys.argv[2] == "dumps":
    file_obj = loads(file_bytes)
    for _ in range(n):
        dumps(file_obj)
elif sys.argv[2] == "loads":
    for _ in range(n):
        loads(file_bytes)