perf(perf): 添加对象静态属性性能测试

- 添加了对象类型的静态属性 $o
- 实现了 static_prop_add_object 测试函数
- 在测试函数中创建 stdClass 对象并设置属性
- 使用 isset 检查对象静态属性的性能测试
- 注释掉原有的性能测试调用
- 添加新的对象静态属性测试用例
pull/1/head
韩天峰 3 months ago
parent feb5041d2e
commit 4757bd353c
  1. 16
      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);
}
Loading…
Cancel
Save