Skip to content

Instantly share code, notes, and snippets.

View machitgarha's full-sized avatar
🤓
Towards an open-source career...

Mohammad Amin Chitgarha machitgarha

🤓
Towards an open-source career...
View GitHub Profile
@machitgarha
machitgarha / array-diff-vs-nuno-array-diff-performance-test.php
Created September 15, 2021 09:31
A tweakable code that compares performance of built-in array_diff() vs nuno_array_diff() (https://gist.github.com/nunoveloso/1992851), and outputs it as a markdown table
<?php
// https://gist.github.com/nunoveloso/1992851
require_once "./nuno-array-diff.php";
const FUNCS = ["array_diff", "nuno_array_diff"];
// Config options
const ARRAY_SIZES_RANGE = [
[100, 1000000],
@machitgarha
machitgarha / array-to-object-benchmark.php
Created May 21, 2021 11:14
Benchmarker for different functions to convert an array to object in PHP (an StackOverflow thread), with a sample data
<?php
/**
* Testing functions' performance posted in the following StackOverflow thread
* (codes are mostly copied from there):
* https://stackoverflow.com/questions/4790453
*
* All these functions convert an array to its object variant.
*
* Also, some of the answers are omitted. Some are duplicated and some doesn't
* even work. Nonetheless, the functionality of these functions is not strictly