This is an automated email from the ASF dual-hosted git repository.
chaokunyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fory.git
The following commit(s) were added to refs/heads/main by this push:
new 9dee0700 fix(python): update python benchmark script (#2315)
9dee0700 is described below
commit 9dee0700a645dcbdeed0a92e9ad25523a9d65f86
Author: penguin_wwy <[email protected]>
AuthorDate: Mon Jun 9 02:01:45 2025 +0800
fix(python): update python benchmark script (#2315)
<!--
**Thanks for contributing to Fory.**
**If this is your first time opening a PR on fory, you can refer to
[CONTRIBUTING.md](https://github.com/apache/fory/blob/main/CONTRIBUTING.md).**
Contribution Checklist
- The **Apache Fory (incubating)** community has restrictions on the
naming of pr titles. You can also find instructions in
[CONTRIBUTING.md](https://github.com/apache/fory/blob/main/CONTRIBUTING.md).
- Fory has a strong focus on performance. If the PR you submit will have
an impact on performance, please benchmark it first and provide the
benchmark result here.
-->
## What does this PR do?
<!-- Describe the purpose of this PR. -->
## Related issues
<!--
Is there any related issue? Please attach here.
- #xxxx0
- #xxxx1
- #xxxx2
-->
## Does this PR introduce any user-facing change?
<!--
If any user-facing interface changes, please [open an
issue](https://github.com/apache/fory/issues/new/choose) describing the
need to do so and update the document if necessary.
-->
- [ ] Does this PR introduce any public API change?
- [ ] Does this PR introduce any binary protocol compatibility change?
## Benchmark
<!--
When the PR has an impact on performance (if you don't know whether the
PR will have an impact on performance, you can submit the PR first, and
if it will have impact on performance, the code reviewer will explain
it), be sure to attach a benchmark data here.
-->
---------
Co-authored-by: wenyangwang <[email protected]>
---
.../cpython_benchmark/fory_benchmark.py | 28 ++++++++++++++++++----
python/pyproject.toml | 2 +-
2 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/integration_tests/cpython_benchmark/fory_benchmark.py
b/integration_tests/cpython_benchmark/fory_benchmark.py
index eb4f7cd1..e2e5ae0d 100644
--- a/integration_tests/cpython_benchmark/fory_benchmark.py
+++ b/integration_tests/cpython_benchmark/fory_benchmark.py
@@ -16,7 +16,6 @@
# under the License.
import argparse
-import array
from dataclasses import dataclass
import datetime
import os
@@ -146,8 +145,7 @@ COMPLEX_OBJECT = ComplexObject1(
f8=2**63 - 1,
f9=1.0 / 2,
f10=1 / 3.0,
- f11=array.array("h", [1, 2]),
- f12=[-1, 4],
+ f11=[-1, 4],
)
@@ -157,6 +155,13 @@ def fory_object(language, ref_tracking, obj):
fory.deserialize(binary)
+def fory_data_class(language, ref_tracking, obj, register_callable):
+ fory = pyfory.Fory(language=language, ref_tracking=ref_tracking)
+ register_callable(fory)
+ binary = fory.serialize(obj)
+ fory.deserialize(binary)
+
+
def benchmark_args():
parser = argparse.ArgumentParser(description="Fory Benchmark")
parser.add_argument("--xlang", action="store_true", default=False)
@@ -190,7 +195,6 @@ def micro_benchmark():
runner.bench_func(
"fory_large_tuple", fory_object, language, not args.no_ref, LARGE_TUPLE
)
- runner.bench_func("fory_list", fory_object, language, not args.no_ref,
LIST)
runner.bench_func(
"fory_large_float_tuple",
fory_object,
@@ -209,8 +213,22 @@ def micro_benchmark():
runner.bench_func(
"fory_large_list", fory_object, language, not args.no_ref, LARGE_LIST
)
+
+ def register_complex(fory):
+ if args.xlang:
+ fory.register_type(ComplexObject1,
typename="example.ComplexObject1")
+ fory.register_type(ComplexObject2,
typename="example.ComplexObject2")
+ else:
+ fory.register_type(ComplexObject1)
+ fory.register_type(ComplexObject2)
+
runner.bench_func(
- "fory_complex", fory_object, language, not args.no_ref, COMPLEX_OBJECT
+ "fory_complex",
+ fory_data_class,
+ language,
+ not args.no_ref,
+ COMPLEX_OBJECT,
+ register_complex,
)
diff --git a/python/pyproject.toml b/python/pyproject.toml
index 4891b7b8..c7aa3f07 100644
--- a/python/pyproject.toml
+++ b/python/pyproject.toml
@@ -58,7 +58,7 @@ format = ["pyarrow"]
all = ["pyarrow"]
[tool.setuptools]
-packages = ["pyfory", "pyfory.format", "pyfory.lib.mmh3"]
+packages = ["pyfory", "pyfory.format", "pyfory.lib", "pyfory.meta"]
include-package-data = true
zip-safe = false
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]