From 4757bd353cc9aeb430d4ccbc2ed6c16c908b70a4 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Wed, 10 Jun 2026 15:31:43 +0800 Subject: [PATCH] =?UTF-8?q?perf(perf):=20=E6=B7=BB=E5=8A=A0=E5=AF=B9?= =?UTF-8?q?=E8=B1=A1=E9=9D=99=E6=80=81=E5=B1=9E=E6=80=A7=E6=80=A7=E8=83=BD?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加了对象类型的静态属性 $o - 实现了 static_prop_add_object 测试函数 - 在测试函数中创建 stdClass 对象并设置属性 - 使用 isset 检查对象静态属性的性能测试 - 注释掉原有的性能测试调用 - 添加新的对象静态属性测试用例 --- perf/class-static-prop.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/perf/class-static-prop.php b/perf/class-static-prop.php index 7e066911..01854fa3 100644 --- a/perf/class-static-prop.php +++ b/perf/class-static-prop.php @@ -3,6 +3,7 @@ use native_types; class Foo { static public int $a; + static public object $o; } function isset_static(int $n) { @@ -19,7 +20,18 @@ function static_prop_add(int $n) { var_dump(Foo::$a); } +function static_prop_add_object(int $n) +{ + Foo::$o = new stdClass(); + Foo::$o->a = 'hello world'; + for ($i = 0; $i < $n; ++$i) { + $x = isset(Foo::$o); + } + var_dump(Foo::$o); +} + function main(): void { - isset_static(100000); - static_prop_add(100000); +// isset_static(100000); +// static_prop_add(100000); + static_prop_add_object(1000); } \ No newline at end of file