baseline测试
Some checks failed
Build wheels / build (ubuntu-latest, 3.11) (push) Has been cancelled
Build wheels / build (ubuntu-latest, 3.12) (push) Has been cancelled
Build wheels / build (ubuntu-latest, 3.13) (push) Has been cancelled
Tests / check (push) Has been cancelled
Tests / build (ubuntu-latest, 3.11) (push) Has been cancelled
Tests / build (ubuntu-latest, 3.12) (push) Has been cancelled
Tests / build (ubuntu-latest, 3.13) (push) Has been cancelled

This commit is contained in:
2026-04-22 18:48:06 +08:00
parent 4b7fc931ba
commit a96b71a8bc
3 changed files with 83 additions and 0 deletions

27
tests/contract.py Normal file
View File

@@ -0,0 +1,27 @@
import time
import pickle
def run(input="tree.pkl"):
with open(input, "rb") as f:
data = pickle.load(f)
sliced_tree = data["sliced_tree"]
arrays = data["arrays"]
n_slices = sliced_tree.nslices
print(f"Total slices: {n_slices}")
t0 = time.perf_counter()
total = sum(sliced_tree.contract_slice(arrays, i, backend='numpy',implementation='cotengra') for i in range(n_slices))
t1 = time.perf_counter()
print(f"Contract: {t1 - t0:.4f} s")
#print(f"Result: {total:.10f}")
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--input", type=str, default="tree.pkl.bak")
args = parser.parse_args()
run(args.input)