Git Product home page Git Product logo

php-arrays-in-memory-comparison's Introduction

Data

11kk items in 101 json file 1.5MB each. https://github.com/sat2707/hlcupdocs/tree/master/data/FULL/data

schema:

  • id — unique id: int32 unsigned
  • location — location id: int32 unsigned
  • user — user id: int32 unsigned
  • visited_at — timestamp.
  • mark — int from 0 to 5

Example:
{"visits": [{"user": 34, "location": 6, "visited_at": 1330898799, "id": 1, "mark": 4}, ...]}
$row = ["user" => 34, "location" => 6, "visited_at" => 1330898799, "id" => 1, "mark" => 4];

Results (on php7 x64):

memory, Mb initializing filling
php array of objects 6231 $visits = new SplFixedArray(11000000); $visits[$row['id']] = (object) $row;
php array (hash) 6057 $visits = []; $visits[$row['id']] = $row;
php SplFixedArray 5696 $visits = new SplFixedArray(11000000); $visits[$row['id']] = $row;
php array (index) 3936 $visits = new SplFixedArray(11000000); $visits[$row['id']] = [$row['user'],...];
redis mset 3354 MSet(["u{$row['id']}" => $row['user'], "l{$row['id']}" => $row['location'], ...])
php SplFixedArray 2790 $visits = new SplFixedArray(11000000); $visits[$row['id']] = new SplFixedArray(4);
php swoole_table 2200 $visits = new swoole_table(11000000); $visits->set($row['id'], $row);
php arrays 2147 $user = $location = ... = []; $user[$row['id']] = $row['user'];$location[$row['id']] = $row['location'];...
php my object 1430 $visits = new SplFixedArray(11000000); $visits[$row['id']] = new MyArrayClass($row['user'], ...);
redis hmset 1409 hMSet("v{$row['id']}", ['user' => $row['user'], 'location' => $row['location'], ...]);
redis hmset 1225 hMSet("v{$row['id']}", ['u' => $row['user'], 'l' => $row['location'], ...]);
memsql insert 842 create table insert into
node.js array 780 visits = []; visits[visitsData.visits[y]['id']] = {user:visitsData.visits[y].user,...}
php strings 736 $visits = new SplFixedArray(11000000); $visits[$row['id']] = join(',', [$row['user'], $row['location'], ...]);
php SplFixedArrays 704 $user = new SplFixedArray(11000000);... $user[$row['id']] = $row['user'];$location[$row['id']] = $row['location'];...
sqlite insert 623 create table insert into
php swoole_pack 539 shmop_open($k, "c", 0644, 49*11000000); swoole_pack(['user' => $row['user'], 'location' => $row['location'], ...])
tarantool insert 530 create_index('primary', ...) insert($row['id'], $row['user'], $row['location'], ...]);
mysql insert 515 create table insert into
node.js arrays 514 visits_user = []; visits_location = [];... visits_user[visitsData.visits[y]['id']] = visitsData.visits[y].user;...
php swoole_pack 341 shmop_open($k, "c", 0644, 31*11000000); swoole_pack(['u' => $row['user'], 'l' => $row['location'], ...])
php swoole_pack 209 shmop_open($k, "c", 0644, 19*11000000); swoole_pack([$row['user'], $row['location'], $row['visited_at'], $row['mark']]);
php pack 143 shmop_open($k, "c", 0644, 13*11000000); pack('LLLc', $row['user'], $row['location'], $row['visited_at'], $row['mark']);

php-arrays-in-memory-comparison's People

Contributors

andrewbo avatar morozovsk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

php-arrays-in-memory-comparison's Issues

How about generators?

Is there a particular reason you did not use generators?

It could reduce your whole memory consumption to a whole new level.

image

Store/lookup times

It would be fantastic if you included a storage/lookup time for each method, too.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.