obstruct 0.3.0__tar.gz → 0.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. {obstruct-0.3.0 → obstruct-0.4.0}/.idea/workspace.xml +2 -0
  2. obstruct-0.4.0/BENCHMARK_TEST.md +183 -0
  3. {obstruct-0.3.0 → obstruct-0.4.0}/PKG-INFO +1 -1
  4. obstruct-0.4.0/src/obstruct/__version__.py +1 -0
  5. obstruct-0.4.0/test/test_speed.py +162 -0
  6. obstruct-0.3.0/src/obstruct/__version__.py +0 -1
  7. obstruct-0.3.0/test/test_speed.py +0 -104
  8. {obstruct-0.3.0 → obstruct-0.4.0}/.idea/.gitignore +0 -0
  9. {obstruct-0.3.0 → obstruct-0.4.0}/.idea/inspectionProfiles/Project_Default.xml +0 -0
  10. {obstruct-0.3.0 → obstruct-0.4.0}/.idea/inspectionProfiles/profiles_settings.xml +0 -0
  11. {obstruct-0.3.0 → obstruct-0.4.0}/.idea/misc.xml +0 -0
  12. {obstruct-0.3.0 → obstruct-0.4.0}/.idea/modules.xml +0 -0
  13. {obstruct-0.3.0 → obstruct-0.4.0}/.idea/obstruct.iml +0 -0
  14. {obstruct-0.3.0 → obstruct-0.4.0}/.idea/vcs.xml +0 -0
  15. {obstruct-0.3.0 → obstruct-0.4.0}/README.md +0 -0
  16. {obstruct-0.3.0 → obstruct-0.4.0}/pyproject.toml +0 -0
  17. {obstruct-0.3.0 → obstruct-0.4.0}/src/obstruct/__init__.py +0 -0
  18. {obstruct-0.3.0 → obstruct-0.4.0}/src/obstruct/aot/__init__.py +0 -0
  19. {obstruct-0.3.0 → obstruct-0.4.0}/src/obstruct/aot/aot.py +0 -0
  20. {obstruct-0.3.0 → obstruct-0.4.0}/src/obstruct/aot/base.py +0 -0
  21. {obstruct-0.3.0 → obstruct-0.4.0}/src/obstruct/aot/pack.py +0 -0
  22. {obstruct-0.3.0 → obstruct-0.4.0}/src/obstruct/aot/unpack.py +0 -0
  23. {obstruct-0.3.0 → obstruct-0.4.0}/src/obstruct/metadata_marks.py +0 -0
  24. {obstruct-0.3.0 → obstruct-0.4.0}/src/obstruct/methods.py +0 -0
  25. {obstruct-0.3.0 → obstruct-0.4.0}/src/obstruct/struct_type.py +0 -0
  26. {obstruct-0.3.0 → obstruct-0.4.0}/src/obstruct/types/__init__.py +0 -0
  27. {obstruct-0.3.0 → obstruct-0.4.0}/src/obstruct/types/base.py +0 -0
  28. {obstruct-0.3.0 → obstruct-0.4.0}/src/obstruct/types/types.py +0 -0
  29. {obstruct-0.3.0 → obstruct-0.4.0}/src/obstruct/types/types.pyi +0 -0
  30. {obstruct-0.3.0 → obstruct-0.4.0}/test/test.py +0 -0
  31. {obstruct-0.3.0 → obstruct-0.4.0}/uv.lock +0 -0
@@ -5,6 +5,8 @@
5
5
  </component>
6
6
  <component name="ChangeListManager">
7
7
  <list default="true" id="b482b6b4-48ce-4be1-bf3c-a72ec254fa35" name="更改" comment="fix: 更新版本号至 0.2.15,修复延迟加载不会应用到类属性的问题">
8
+ <change afterPath="$PROJECT_DIR$/BENCHMARK_TEST.md" afterDir="false" />
9
+ <change beforePath="$PROJECT_DIR$/src/obstruct/__version__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/obstruct/__version__.py" afterDir="false" />
8
10
  <change beforePath="$PROJECT_DIR$/src/obstruct/aot/base.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/obstruct/aot/base.py" afterDir="false" />
9
11
  <change beforePath="$PROJECT_DIR$/src/obstruct/aot/unpack.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/obstruct/aot/unpack.py" afterDir="false" />
10
12
  <change beforePath="$PROJECT_DIR$/test/test_speed.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/test_speed.py" afterDir="false" />
@@ -0,0 +1,183 @@
1
+ ## 基准测试性能分析报告
2
+
3
+ > 此报告由 **DeepSeek (offical)** 生成
4
+
5
+ > 测试配置:1000 steps/轮,128 轮采样,32 次去极值。
6
+
7
+ ---
8
+
9
+ ## 一、测试结构与参数
10
+
11
+ | 项目 | 值 | 补充 |
12
+ |----------------|----------------|--------------------------------------------------|
13
+ | 简单结构大小 | 42 bytes | 12 个基本类型字段
14
+ | 复杂结构大小 | 484 bytes | 包含两个简单数据结构以及一个长度 100 的 int 数组
15
+ | 每轮迭代步数 | **1,000** | 无
16
+ | 结果实际采样数 | **64** | 无
17
+ | 总操作次数 | 64,000 次/方法 | 无
18
+
19
+ ---
20
+
21
+ ## 二、按耗时排序(从快到慢)
22
+
23
+ | 排名 | 测试名称 | 平均耗时 (ns) | 相对 Pack 倍数 |
24
+ |:----:|--------------------------------|:-------------:|:--------------:|
25
+ | 1 | **Pack** | **261.955** | 1.00x |
26
+ | 2 | **Update From** | 331.223 | 1.26x |
27
+ | 3 | **Update** | 377.706 | 1.44x |
28
+ | 4 | **Unpack From** | 501.742 | 1.92x |
29
+ | 5 | **Unpack** | 601.889 | 2.30x |
30
+ | 6 | **Complex Update** | 825.573 | 3.15x |
31
+ | 7 | **Complex Update From (100x)** | 965.261 | 3.68x |
32
+ | 8 | **Complex Unpack From (100x)** | 1,366.177 | 5.22x |
33
+ | 9 | **Complex Pack** | 1,469.102 | 5.61x |
34
+ | 10 | **Complex Unpack** | 1,986.633 | 7.58x |
35
+ | 11 | **Iter Update (100x)** | 29,666.533 | 113.25x |
36
+ | 12 | **Iter Unpack (100x)** | 42,771.392 | 163.28x |
37
+ | 13 | **Complex Iter Update (100x)** | 95,885.616 | 366.03x |
38
+ | 14 | **Complex Iter Unpack (100x)** | 144,415.439 | 551.30x |
39
+
40
+ ---
41
+
42
+ ## 三、按方法类型分组对比
43
+
44
+ ### 3.1 简单方法
45
+
46
+ | 方法 | 耗时 (ns) | 相对 Pack | 备注 |
47
+ |-------------|:---------:|:---------:|-------------------------|
48
+ | Pack | 261.955 | 1.00x | 基准 |
49
+ | Update From | 331.223 | 1.26x | 复用 + 偏移,最快更新类 |
50
+ | Update | 377.706 | 1.44x | 复用对象 |
51
+ | Unpack From | 501.742 | 1.92x | 带偏移 |
52
+ | Unpack | 601.889 | 2.30x | 新建对象,最慢简单方法 |
53
+
54
+ ### 3.2 复杂方法
55
+
56
+ | 方法 | 耗时 (ns) | 相对 Pack | 备注 |
57
+ |---------------------|:---------:|:---------:|---------------------------|
58
+ | Complex Update | 825.573 | 3.15x | 复用对象,钩子触发 |
59
+ | Complex Update From | 965.261 | 3.68x | 复用 + 偏移,钩子触发 |
60
+ | Complex Unpack From | 1,366.177 | 5.22x | 带偏移,钩子触发 |
61
+ | Complex Pack | 1,469.102 | 5.61x | 打包 |
62
+ | Complex Unpack | 1,986.633 | 7.58x | 新建对象 + 钩子,最慢单次 |
63
+
64
+ ### 3.3 迭代方法
65
+
66
+ | 方法 | 耗时 (ns) | 相对 Pack | 每元素耗时 |
67
+ |----------------------------|:-----------:|:---------:|:-----------:|
68
+ | Iter Update (100x) | 29,666.533 | 113.25x | 296.67 ns |
69
+ | Iter Unpack (100x) | 42,771.392 | 163.28x | 427.71 ns |
70
+ | Complex Iter Update (100x) | 95,885.616 | 366.03x | 958.86 ns |
71
+ | Complex Iter Unpack (100x) | 144,415.439 | 551.30x | 1,444.15 ns |
72
+
73
+ ---
74
+
75
+ ## 四、关键性能对比
76
+
77
+ ### 4.1 复用 vs 新建对象
78
+
79
+ | 对比组 | 新建 (unpack) | 复用 (update) | 性能提升 |
80
+ |-------------|:--------------:|:-------------:|:----------:|
81
+ | 简单 | 601.889 ns | 377.706 ns | **+37.3%** |
82
+ | 简单 + 偏移 | 501.742 ns | 331.223 ns | **+34.0%** |
83
+ | 复杂 | 1,986.633 ns | 825.573 ns | **+58.5%** |
84
+ | 复杂 + 偏移 | 1,366.177 ns | 965.261 ns | **+29.3%** |
85
+ | 迭代 | 42,771.392 ns | 29,666.533 ns | **+30.6%** |
86
+ | 复杂迭代 | 144,415.439 ns | 95,885.616 ns | **+33.6%** |
87
+
88
+ ### 4.2 简单 vs 复杂(同类型对比)
89
+
90
+ | 对比组 | 简单耗时 | 复杂耗时 | 倍数 |
91
+ |-------------|:-------------:|:--------------:|:---------:|
92
+ | Pack | 261.955 ns | 1,469.102 ns | **5.61x** |
93
+ | Unpack | 601.889 ns | 1,986.633 ns | **3.30x** |
94
+ | Update | 377.706 ns | 825.573 ns | **2.19x** |
95
+ | Update From | 331.223 ns | 965.261 ns | **2.91x** |
96
+ | Iter Unpack | 42,771.392 ns | 144,415.439 ns | **3.38x** |
97
+ | Iter Update | 29,666.533 ns | 95,885.616 ns | **3.23x** |
98
+
99
+ ### 4.3 单次 vs 迭代(每元素对比)
100
+
101
+ 迭代方法将 100 次操作合并为 1 次调用,按每元素耗时对比:
102
+
103
+ | 方法 | 单次调用 (ns) | 每元素 (ns) | 单次 vs 迭代每元素 |
104
+ |----------------------------|:-------------:|:-----------:|:----------------------:|
105
+ | Unpack | 601.889 | — | 迭代每元素快 **28.9%** |
106
+ | Iter Unpack (100x) | 42,771.392 | 427.714 | |
107
+ | Update | 377.706 | — | 迭代每元素快 **21.5%** |
108
+ | Iter Update (100x) | 29,666.533 | 296.665 | |
109
+ | Complex Unpack | 1,986.633 | — | 迭代每元素快 **27.3%** |
110
+ | Complex Iter Unpack (100x) | 144,415.439 | 1,444.154 | |
111
+ | Complex Update | 825.573 | — | 迭代每元素快 **16.2%** |
112
+ | Complex Iter Update (100x) | 95,885.616 | 958.856 | |
113
+
114
+ ---
115
+
116
+ ## 五、基准测试汇总表
117
+
118
+ | # | 测试名称 | 耗时 (ns) | 耗时 (µs) | 相对 Pack | 相对同组最优 | 钩子 |
119
+ |:--:|--------------------------------|:-----------:|:---------:|:---------:|:------------:|:----:|
120
+ | 1 | **Pack** | 261.955 | 0.262 | 1.00x | 基准 | ❌ |
121
+ | 2 | **Update From** | 331.223 | 0.331 | 1.26x | 最快更新 | ❌ |
122
+ | 3 | **Update** | 377.706 | 0.378 | 1.44x | — | ❌ |
123
+ | 4 | **Unpack From** | 501.742 | 0.502 | 1.92x | 最快解包 | ❌ |
124
+ | 5 | **Unpack** | 601.889 | 0.602 | 2.30x | — | ❌ |
125
+ | 6 | **Complex Update** | 825.573 | 0.826 | 3.15x | 最快复杂 | ✅ |
126
+ | 7 | **Complex Update From** | 965.261 | 0.965 | 3.68x | — | ✅ |
127
+ | 8 | **Complex Unpack From** | 1,366.177 | 1.366 | 5.22x | — | ✅ |
128
+ | 9 | **Complex Pack** | 1,469.102 | 1.469 | 5.61x | — | ❌ |
129
+ | 10 | **Complex Unpack** | 1,986.633 | 1.987 | 7.58x | 最慢单次 | ✅ |
130
+ | 11 | **Iter Update (100x)** | 29,666.533 | 29.667 | 113.25x | 最快迭代 | ❌ |
131
+ | 12 | **Iter Unpack (100x)** | 42,771.392 | 42.771 | 163.28x | — | ❌ |
132
+ | 13 | **Complex Iter Update (100x)** | 95,885.616 | 95.886 | 366.03x | — | ✅ |
133
+ | 14 | **Complex Iter Unpack (100x)** | 144,415.439 | 144.415 | 551.30x | 最慢总榜 | ✅ |
134
+
135
+ ---
136
+
137
+ ## 六、可视化性能分布
138
+
139
+ ```
140
+ Pack ████████████████████████████████████████████████████████████████████ 261.955 ns
141
+ Update From ██████████████████████████████████████████████████████████████████ 331.223 ns
142
+ Update █████████████████████████████████████████████████████████████████ 377.706 ns
143
+ Unpack From ████████████████████████████████████████████████████████████████████ 501.742 ns
144
+ Unpack ███████████████████████████████████████████████████████████████████ 601.889 ns
145
+ Complex Upd ███████████████████████████████████████████████████████████████████ 825.573 ns
146
+ Complex UpF ███████████████████████████████████████████████████████████████████ 965.261 ns
147
+ Complex UnF ███████████████████████████████████████████████████████████████████ 1,366 ns
148
+ Complex Pack ███████████████████████████████████████████████████████████████████ 1,469 ns
149
+ Complex Unp ███████████████████████████████████████████████████████████████████ 1,987 ns
150
+ ─────────────────────────────────────────────────────────────────────────────────────────
151
+ Iter Update ███████████████████████████████████████████████████████████████████ 29,667 ns
152
+ Iter Unpack ███████████████████████████████████████████████████████████████████ 42,771 ns
153
+ Cplx Iter Up ███████████████████████████████████████████████████████████████████ 95,886 ns
154
+ Cplx Iter Un ███████████████████████████████████████████████████████████████████ 144,415 ns
155
+ ```
156
+
157
+ ---
158
+
159
+ ## 七、核心结论
160
+
161
+ | 维度 | 结论 |
162
+ |------------------|-----------------------------------------------------|
163
+ | **最快单次操作** | `Pack` (261.96 ns) |
164
+ | **最快解析操作** | `Update From` (331.22 ns) |
165
+ | **最慢单次操作** | `Complex Unpack` (1,986.63 ns),比最快慢 **7.58x** |
166
+ | **复用提升** | 复杂场景下 `update` 比 `unpack` 快 **58.5%** |
167
+ | **偏移影响** | `unpack_from` 比 `unpack` 快 **16.6%**(简单) |
168
+ | **迭代效率** | `iter_update` 比 `iter_unpack` 快 **30.6%**(简单) |
169
+ | **复杂度代价** | 复杂 Pack 比简单 Pack 慢 **5.61x** |
170
+ | **钩子代价** | `__post_unpack__` 增加约 **35%** 开销 |
171
+
172
+ ---
173
+
174
+ ## 八、最终建议
175
+
176
+ | 场景 | 推荐 | 理由 |
177
+ |-----------------------|------------------------------------------|--------------------------------------------|
178
+ | **高频单次解析** | `update_from` | 最快解析方法,复用 + 偏移 |
179
+ | **需要新建对象** | `unpack_from` | 比 `unpack` 快 16.6% |
180
+ | **批量解析(100次)** | `iter_update` | 比 `iter_unpack` 快 30.6%,每元素仅 296 ns |
181
+ | **复杂结构批量解析** | `complex_iter_update` | 比 `complex_iter_unpack` 快 33.6% |
182
+ | **避免使用** | `complex_unpack` | 单次最慢,新建对象 + 钩子双重开销 |
183
+ | **极致性能** | 手动 `memoryview` + `struct.unpack_from` | 避免切片拷贝和对象分配 |
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: obstruct
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Author-email: LittleNightSong <LittleNightSongYO@outlook.com>
5
5
  Classifier: Development Status :: 3 - Alpha
6
6
  Classifier: Programming Language :: Python
@@ -0,0 +1 @@
1
+ version = "0.4.0"
@@ -0,0 +1,162 @@
1
+ import dataclasses
2
+ import time
3
+ from array import array
4
+ from typing import Annotated
5
+
6
+ import obstruct as obs
7
+
8
+
9
+ def run_iterator(iterator):
10
+ [i for i in iterator]
11
+
12
+
13
+ @dataclasses.dataclass()
14
+ class MyStruct(obs.Struct):
15
+ a: int
16
+ b: int
17
+ c: float
18
+ d: int
19
+ e: obs.short
20
+ f: obs.unsigned_short
21
+ g: obs.long
22
+ h: obs.unsigned_long
23
+ i: obs.unsigned_long
24
+ j: obs.char
25
+ k: obs.unsigned_char
26
+ l: obs.long_long
27
+
28
+ def __post_unpack__(self):
29
+ global is_post_unpack_called
30
+ is_post_unpack_called = True
31
+
32
+
33
+ @dataclasses.dataclass()
34
+ class AnotherStruct(obs.Struct):
35
+ x: MyStruct
36
+ y: Annotated[array[int], 100]
37
+ z: MyStruct
38
+
39
+
40
+ MyStruct.__compile_struct__()
41
+ AnotherStruct.__compile_struct__()
42
+
43
+ print('MyStruct size', MyStruct.__cstruct__.size)
44
+ print('AnotherStruct size', AnotherStruct.__cstruct__.size)
45
+
46
+ is_post_unpack_called = False
47
+
48
+ data = MyStruct(
49
+ 1, 2, 1.0, 4, 5, 6, 7, 8, 9, b'8', 1, 2
50
+ )
51
+
52
+ packed_data = data.pack()
53
+ packed_data_100 = packed_data * 100
54
+
55
+ complex_data = AnotherStruct(data, array('i', [100] * 100), data)
56
+ packed_complex_data = complex_data.pack()
57
+ packed_complex_data_100 = packed_complex_data * 100
58
+
59
+
60
+ def test_timeit(name, code, extra="print('Post Hook Called:', is_post_unpack_called); is_post_unpack_called=False"):
61
+ import timeit
62
+
63
+ res = timeit.repeat(
64
+ code,
65
+ number=NUMBER,
66
+ repeat=REPEAT,
67
+ timer=time.perf_counter_ns,
68
+ globals=globals()
69
+ )
70
+
71
+ print()
72
+ # print(len(res))
73
+
74
+ for i in range(SORT):
75
+ res.remove(max(res))
76
+ res.remove(min(res))
77
+
78
+ print("Test: ", name)
79
+ print("Results Length:", len(res))
80
+
81
+ print(f'{NUMBER} steps finished in {sum(res) / (len(res)):.3f} ns')
82
+ print(f'Average: {sum(res) / (len(res)) / NUMBER:.3f} ns per step', '\n\n')
83
+
84
+ exec(extra, globals=globals()) if extra else None
85
+
86
+
87
+ # print("\n\nMyStruct:", MyStruct.__cstruct__.size)
88
+ print("AnotherStruct:", AnotherStruct.__cstruct__.size, '\n\n')
89
+
90
+ NUMBER = 1000
91
+ REPEAT = 128
92
+ SORT = 32
93
+
94
+ test_timeit(
95
+ name='Pack',
96
+ code="""data.pack()""",
97
+ )
98
+
99
+ test_timeit(
100
+ name='Unpack',
101
+ code="""MyStruct.unpack(packed_data)""",
102
+ )
103
+
104
+ test_timeit(
105
+ name='Complex Pack',
106
+ code="""complex_data.pack()""",
107
+ )
108
+
109
+ test_timeit(
110
+ name='Complex Unpack',
111
+ code="""AnotherStruct.unpack(packed_complex_data)""",
112
+ )
113
+
114
+ test_timeit(
115
+ name='Update',
116
+ code="""data.update(packed_data)"""
117
+ )
118
+
119
+ test_timeit(
120
+ name='Iter Unpack (100x)',
121
+ code="""run_iterator(MyStruct.iter_unpack(packed_data_100))"""
122
+ )
123
+
124
+ test_timeit(
125
+ name='Iter Update (100x)',
126
+ code="""run_iterator(MyStruct.iter_update(packed_data_100, obj=data))"""
127
+ )
128
+
129
+ test_timeit(
130
+ name='Unpack From',
131
+ code="""MyStruct.unpack_from(packed_data)"""
132
+ )
133
+
134
+ test_timeit(
135
+ name='Update From',
136
+ code="""data.update_from(packed_data)"""
137
+ )
138
+
139
+ test_timeit(
140
+ name='Complex Update',
141
+ code="""complex_data.update(packed_complex_data)"""
142
+ )
143
+
144
+ test_timeit(
145
+ name='Complex Iter Unpack (100x)',
146
+ code="""run_iterator(AnotherStruct.iter_unpack(packed_complex_data_100))"""
147
+ )
148
+
149
+ test_timeit(
150
+ name='Complex Iter Update (100x)',
151
+ code="""run_iterator(AnotherStruct.iter_update(packed_complex_data_100, obj=complex_data))"""
152
+ )
153
+
154
+ test_timeit(
155
+ name='Complex Unpack From (100x)',
156
+ code="""AnotherStruct.unpack_from(packed_complex_data)"""
157
+ )
158
+
159
+ test_timeit(
160
+ name='Complex Update From (100x)',
161
+ code="""complex_data.update_from(packed_complex_data)"""
162
+ )
@@ -1 +0,0 @@
1
- version = "0.3.0"
@@ -1,104 +0,0 @@
1
- import dataclasses
2
- import time
3
- from array import array
4
- from typing import Annotated
5
-
6
- import obstruct as obs
7
-
8
-
9
- @dataclasses.dataclass()
10
- class MyStruct(obs.Struct):
11
- a: int
12
- b: int
13
- c: float
14
- d: int
15
- e: obs.short
16
- f: obs.unsigned_short
17
- g: obs.long
18
- h: obs.unsigned_long
19
- i: obs.unsigned_long
20
- j: obs.char
21
- k: obs.unsigned_char
22
- l: obs.long_long
23
-
24
- def __post_unpack__(self):
25
- ...
26
-
27
-
28
- @dataclasses.dataclass()
29
- class AnotherStruct(obs.Struct):
30
- x: MyStruct
31
- y: Annotated[array[int], 100]
32
- z: MyStruct
33
-
34
-
35
- MyStruct.__compile_struct__()
36
- AnotherStruct.__compile_struct__()
37
-
38
- print('MyStruct size', MyStruct.__cstruct__.size)
39
- print('AnotherStruct size', AnotherStruct.__cstruct__.size)
40
-
41
-
42
- # data = MyStruct(
43
- # 1,2,1.0,4,5,6,7,8,9,b'8',1,2
44
- # )
45
- #
46
- # packed_data = data.pack()
47
-
48
-
49
- # complex_data = AnotherStruct(data, array('i', [100]*100), data)
50
- # packed_complex_data = complex_data.pack()
51
-
52
-
53
- def test_timeit(name, code):
54
- import timeit
55
-
56
- print("Test: ", name)
57
- res = timeit.repeat(
58
- code,
59
- number=NUMBER,
60
- repeat=REPEAT,
61
- timer=time.perf_counter_ns,
62
- globals=globals()
63
- )
64
-
65
- print(len(res))
66
-
67
- for i in range(SORT):
68
- res.remove(max(res))
69
- res.remove(min(res))
70
-
71
- print("Results Length:", len(res))
72
-
73
- print(f'{NUMBER} steps finished in {sum(res)/(len(res)):.3f} ns')
74
- print(f'Average: {sum(res)/(len(res))/NUMBER:.3f} ns per step', '\n\n')
75
-
76
-
77
- # print("\n\nMyStruct:", MyStruct.__cstruct__.size)
78
- print("AnotherStruct:", AnotherStruct.__cstruct__.size, '\n\n')
79
-
80
- NUMBER = 10000
81
- REPEAT = 128
82
- SORT = 32
83
-
84
- # test_timeit(
85
- # name='Pack',
86
- # code="""data.pack()""",
87
- # )
88
- #
89
- # test_timeit(
90
- # name='Unpack',
91
- # code="""MyStruct.unpack(packed_data)""",
92
- # )
93
- #
94
- #
95
- #
96
- # test_timeit(
97
- # name='Complex Pack',
98
- # code="""complex_data.pack()""",
99
- # )
100
- #
101
- # test_timeit(
102
- # name='Complex Unpack',
103
- # code="""AnotherStruct.unpack(packed_complex_data)""",
104
- # )
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes