Skip to content

Added bench for array_merge vs array desctructuring#5

Merged
lyrixx merged 2 commits intomasterfrom
new
Aug 10, 2020
Merged

Added bench for array_merge vs array desctructuring#5
lyrixx merged 2 commits intomasterfrom
new

Conversation

@lyrixx
Copy link
Copy Markdown
Owner

@lyrixx lyrixx commented Jun 2, 2020

+-------------------------+---------+-------+
| subject                 | mean    | diff  |
+-------------------------+---------+-------+
| benchArrayMerge         | 0.162μs | 1.00x |
| benchArrayDestructuring | 0.197μs | 1.21x |
+-------------------------+---------+-------+

+-------------------------+---------+-------+
| subject                 | mean    | diff  |
+-------------------------+---------+-------+
| benchArrayMerge         | 0.162μs | 1.00x |
| benchArrayDestructuring | 0.197μs | 1.21x |
+-------------------------+---------+-------+
Copy link
Copy Markdown
Contributor

@drupol drupol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@Ocramius
Copy link
Copy Markdown

Ocramius commented Jun 2, 2020

Could you try to see if multiple parameters make any difference?

So:

array_merge($a, $b, $c, $d, $e);

vs

[...$a, ...$b, ...$c, ...$d, ...$e];

Wondering if SEND_VAL is measurable here 👍

+----------------------------------+---------+-------+
| subject                          | mean    | diff  |
+----------------------------------+---------+-------+
| benchArrayMerge                  | 0.165μs | 1.00x |
| benchArrayDestructuring          | 0.194μs | 1.18x |
| benchArrayMergeWith5Args         | 0.285μs | 1.73x |
| benchArrayDestructuringWith5Args | 0.378μs | 2.29x |
+----------------------------------+---------+-------+
@lyrixx
Copy link
Copy Markdown
Owner Author

lyrixx commented Jun 2, 2020

@Ocramius Here we go:

+----------------------------------+---------+-------+
| subject                          | mean    | diff  |
+----------------------------------+---------+-------+
| benchArrayMerge                  | 0.165μs | 1.00x |
| benchArrayDestructuring          | 0.194μs | 1.18x |
| benchArrayMergeWith5Args         | 0.285μs | 1.73x |
| benchArrayDestructuringWith5Args | 0.378μs | 2.29x |
+----------------------------------+---------+-------+

@Ocramius
Copy link
Copy Markdown

Ocramius commented Jun 2, 2020

Thanks! Indeed, seems like SEND_VAL is optimized a lot

Possibly not up to you, but it would be interesting to see if opcache optimizations made any difference too (new issue, maybe?)

@Ocramius
Copy link
Copy Markdown

Ocramius commented Jun 2, 2020

Raised in phpbench/phpbench#637

@lyrixx
Copy link
Copy Markdown
Owner Author

lyrixx commented Jun 2, 2020

@Ocramius With the following configuration:

opcache.blacklist_filename => no value => no value
opcache.consistency_checks => 0 => 0
opcache.dups_fix => Off => Off
opcache.enable => On => On
opcache.enable_cli => On => On
opcache.enable_file_override => Off => Off
opcache.error_log => no value => no value
opcache.file_cache => /tmp/php-opcache => /tmp/php-opcache
opcache.file_cache_consistency_checks => 1 => 1
opcache.file_cache_only => 0 => 0
opcache.file_update_protection => 2 => 2
opcache.force_restart_timeout => 180 => 180
opcache.huge_code_pages => Off => Off
opcache.interned_strings_buffer => 8 => 8
opcache.lockfile_path => /tmp => /tmp
opcache.log_verbosity_level => 1 => 1
opcache.max_accelerated_files => 15000 => 15000
opcache.max_file_size => 0 => 0
opcache.max_wasted_percentage => 5 => 5
opcache.memory_consumption => 128 => 128
opcache.opt_debug_level => 0 => 0
opcache.optimization_level => 0x7FFEBFFF => 0x7FFEBFFF
opcache.preferred_memory_model => no value => no value
opcache.preload => no value => no value
opcache.preload_user => no value => no value
opcache.protect_memory => 0 => 0
opcache.restrict_api => no value => no value
opcache.revalidate_freq => 2 => 2
opcache.revalidate_path => Off => Off
opcache.save_comments => 1 => 1
opcache.use_cwd => On => On
opcache.validate_permission => Off => Off
opcache.validate_root => Off => Off
opcache.validate_timestamps => On => On

I got theses values:

+----------------------------------+---------+-------+
| subject                          | mean    | diff  |
+----------------------------------+---------+-------+
| benchArrayMerge                  | 0.169μs | 1.00x |
| benchArrayDestructuring          | 0.201μs | 1.19x |
| benchArrayMergeWith5Args         | 0.295μs | 1.75x |
| benchArrayDestructuringWith5Args | 0.402μs | 2.38x |
+----------------------------------+---------+-------+

(But the cache file is empty 🤔 )

@Ocramius
Copy link
Copy Markdown

Ocramius commented Jun 2, 2020

Yeah, I think this is for upstream tools to figure out: the entire test suite needs to be re-evaluated with opcache on later :)

@lyrixx lyrixx merged commit 1cd85e6 into master Aug 10, 2020
@lyrixx lyrixx deleted the new branch August 10, 2020 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants