{"id":22998130,"url":"https://github.com/patrykbaszak/dedicated-mapper","last_synced_at":"2025-11-18T10:30:16.645Z","repository":{"id":188101654,"uuid":"621416243","full_name":"patrykbaszak/dedicated-mapper","owner":"patrykbaszak","description":"[Deprecated] Dedicated Mapper is a library that generates PHP functions to speed up the mapping process between arrays, objects, and classes. You can include your own callbacks in the mapping process. See, for example, validation during mapping with Symfony Validator.","archived":false,"fork":false,"pushed_at":"2024-06-21T10:03:13.000Z","size":477,"stargazers_count":1,"open_issues_count":11,"forks_count":0,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2024-12-28T17:43:17.966Z","etag":null,"topics":["fast","greencoding","jms-serializer","mapper","performance","serializer","symfony-serializer"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/patrykbaszak.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-30T16:05:42.000Z","updated_at":"2024-06-22T21:04:55.000Z","dependencies_parsed_at":"2024-06-22T03:18:04.861Z","dependency_job_id":null,"html_url":"https://github.com/patrykbaszak/dedicated-mapper","commit_stats":null,"previous_names":["patrykbaszak/dedicated-mapper"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrykbaszak%2Fdedicated-mapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrykbaszak%2Fdedicated-mapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrykbaszak%2Fdedicated-mapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrykbaszak%2Fdedicated-mapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/patrykbaszak","download_url":"https://codeload.github.com/patrykbaszak/dedicated-mapper/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239615293,"owners_count":19668861,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fast","greencoding","jms-serializer","mapper","performance","serializer","symfony-serializer"],"created_at":"2024-12-15T06:11:28.510Z","updated_at":"2025-11-18T10:30:16.576Z","avatar_url":"https://github.com/patrykbaszak.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [Deprecated] Dedicated Mapper (Bundle*) #\n**I present to You the fastest PHP Dedicated Mapper ever created!**\u003cbr\u003e\nIt's even **31** times faster than **JMS Serializer** and even **43** times faster than **Symfony Serializer** in denormalization!\u003cbr\u003e\n\u003csub\u003e*The package supports Symfony Bundle system but not require to be used with Symfony.\u003c/sub\u003e\n\n## Usage\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nnamespace App;\n\nuse PBaszak\\DedicatedMapper\\Expression\\Builder\\ArrayExpressionBuilder as ArrayBuilder;\nuse PBaszak\\DedicatedMapper\\Expression\\Builder\\ReflectionClassExpressionBuilder as ClassBuilder;\nuse PBaszak\\DedicatedMapper\\MapperService;\n\nclass Test\n{\n    private string $name;\n}\n\n$data = [\n    'name' =\u003e 'test';\n];\n$mapper = new MapperService('/app/var/mapper/');\n\n/** @var Test $test */\n$test = $mapper-\u003emap(\n    $data, \n    Test::class,\n    new ArrayBuilder(), # You have to specify $data type, available options: 'array', 'object', 'class object'. In this case it's a `array`\n    new ClassBuilder(), # You have to specify output type, in this case it's `class object` based on the blueprint class `Test`.\n);\n```\n\n## How it works?\nThe **Dedicated Mapper** generates php file which looks like this one *(it's only example for specific case)*:\n\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nreturn function (array $data): PBaszak\\DedicatedMapper\\Tests\\Performance\\SimpleData {\n    $ref_df1d1d13 = new ReflectionClass(PBaszak\\DedicatedMapper\\Tests\\Performance\\SimpleData::class);\n    /** @var PBaszak\\DedicatedMapper\\Tests\\Performance\\SimpleData $output */\n    $output = $ref_df1d1d13-\u003enewInstanceWithoutConstructor();\n\n    if (array_key_exists('name', $data)) {\n        $ref_df1d1d13-\u003egetProperty('name')-\u003esetValue($output, $data['name']);\n    }\n\n    return $output;\n};\n```\n\nand using it in the mapping process.\n\n## Report ##\n### Environment Details\n- **PHP**: 8.2.7 (from Dockerfile and without xdebug)\n- **Docker**: Docker version 20.10.12, build 20.10.12-0ubuntu2~20.04.1\n- **OS**: WSL2 - Ubuntu 20.04.5 LTS, Windows 10 Pro 22H2 19045.3324\n- **CPU**: Intel(R) Core(TM) i5-10400 CPU @ 2.90GHz\n- **RAM**: DDR4 32,0GB 2667MHz\n- **SSD**: Samsung 970 EVO Plus 500GB M.2 2280 PCI-E x4 Gen3 NVMe\n\n\u003e Note:  Each test was run 100 times.\u003cbr\u003e\n\u003e If you want to run the test yourself:\n\u003e ```sh\n\u003e git clone https://github.com/patrykbaszak/dedicated-mapper.git\n\u003e bash start.sh\n\u003e docker exec php composer test:performance\n\u003e ``` \n\n### Comparison Results\n\n#### JMS Serializer vs Dedicated Mapper\n\n| Test Case                         | Metric | JMS Serializer        | Dedicated Mapper       | Performance Gain      |\n|:---------------------------------:|:------:|----------------------:|-----------------------:|----------------------:|\n| Build \u0026 Use                       | avg    | 0.00073563575744629 s | 0.00022567272186279 s  | 3.26x faster          |\n|                                   | min    | 0.00061202049255371 s | 0.0001990795135498 s   | 3.07x faster          |\n|                                   | max    | 0.006666898727417 s   | 0.0012781620025635 s   | 5.22x faster          |\n| Use (one time)                    | avg    | 0.00064053297042847 s | 0.00020017862319946 s  | 3.2x faster           |\n|                                   | min    | 0.00055694580078125 s | 0.00018501281738281 s  | 3.01x faster          |\n|                                   | max    | 0.0044717788696289 s  | 0.0002751350402832 s   | 16.25x faster         |\n| Second Use (Same Data)            | avg    | 0.00031213998794556 s | 5.3181648254395E-5 s   | 5.87x faster          |\n|                                   | min    | 0.00029683113098145 s | 5.0067901611328E-5 s   | 5.93x faster          |\n|                                   | max    | 0.0003669261932373 s  | 7.8916549682617E-5 s   | 4.65x faster          |\n| Second Use (Different Data)       | avg    | 0.00062076330184937 s | 5.8262348175049E-5 s   | 10.65x faster         |\n|                                   | min    | 0.0005500316619873 s  | 5.4836273193359E-5 s   | 10.03x faster         |\n|                                   | max    | 0.0029869079589844 s  | 9.5129013061523E-5 s   | 31.4x faster          |\n\n\n#### Symfony Serializer vs Dedicated Mapper\n\n| Test Case                         | Metric | Symfony Serializer     | Dedicated Mapper       | Performance Gain      |\n|:---------------------------------:|:------:|-----------------------:|-----------------------:|----------------------:|\n| Build \u0026 Use                       | avg    | 0.0021615481376648 s   | 0.00021748304367065 s  | 9.94x faster          |\n|                                   | min    | 0.0019149780273438 s   | 9.3221664428711E-5 s   | 20.54x faster         |\n|                                   | max    | 0.01357889175415 s     | 0.00031518936157227 s  | 43.08x faster         |\n| Use (one time)                    | avg    | 0.0019077062606812 s   | 0.0002018141746521 s   | 9.45x faster          |\n|                                   | min    | 0.0017900466918945 s   | 0.00018596649169922 s  | 9.63x faster          |\n|                                   | max    | 0.0043408870697021 s   | 0.0002748966217041 s   | 15.79x faster         |\n| Second Use (Same Data)            | avg    | 0.0011084413528442 s   | 6.0606002807617E-5 s   | 18.29x faster         |\n|                                   | min    | 0.0010659694671631 s   | 5.5074691772461E-5 s   | 19.35x faster         |\n|                                   | max    | 0.0017890930175781 s   | 0.0001060962677002 s   | 16.86x faster         |\n| Second Use (Different Data)       | avg    | 0.0019117307662964 s   | 6.1674118041992E-5 s   | 31x faster            |\n|                                   | min    | 0.0017828941345215 s   | 5.6028366088867E-5 s   | 31.82x faster         |\n|                                   | max    | 0.0042397975921631 s   | 0.00010395050048828 s  | 40.79x faster         |\n| Build, Use \u0026 Validation           | avg    | 0.0023907327651978 s   | 0.00046631574630737 s  | 5.13x faster          |\n|                                   | min    | 0.002216100692749 s    | 0.00043201446533203 s  | 5.13x faster          |\n|                                   | max    | 0.007519006729126 s    | 0.00083398818969727 s  | 9.02x faster          |\n| Use \u0026 Validation (one time)       | avg    | 0.0022232341766357 s   | 0.00038869619369507 s  | 5.72x faster          |\n|                                   | min    | 0.0020699501037598 s   | 0.0003659725189209 s   | 5.66x faster          |\n|                                   | max    | 0.0052480697631836 s   | 0.0004730224609375 s   | 11.09x faster         |\n| Second Use \u0026 Validation (Same Data) | avg | 0.0012864065170288 s   | 0.00018531322479248 s  | 6.94x faster          |\n|                                   | min    | 0.0012338161468506 s   | 0.00017285346984863 s  | 7.14x faster          |\n|                                   | max    | 0.0020201206207275 s   | 0.0002751350402832 s   | 7.34x faster          |\n| Second Use \u0026 Validation (Different Data) | avg | 0.0021827912330627 s | 0.00018846273422241 s  | 11.58x faster         |\n|                                   | min    | 0.00205397605896 s     | 0.00017499923706055 s  | 11.74x faster         |\n|                                   | max    | 0.0047998428344727 s   | 0.0003211498260498 s   | 14.95x faster         |\n\n\u003csub\u003e*Tables generated using Chat GPT-4 based on test data. This information is here because the chat is not a perfect tool and could mess up the measured times for example.\u003c/sub\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatrykbaszak%2Fdedicated-mapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpatrykbaszak%2Fdedicated-mapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatrykbaszak%2Fdedicated-mapper/lists"}