{"id":20461823,"url":"https://github.com/kripton/rp2040-compressiontest","last_synced_at":"2025-09-24T21:30:59.390Z","repository":{"id":149480615,"uuid":"374813290","full_name":"kripton/rp2040-compressiontest","owner":"kripton","description":"Small benchmark of different compression algorithms on the RP2040","archived":false,"fork":false,"pushed_at":"2023-02-10T22:00:19.000Z","size":44,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-11-15T12:35:18.185Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kripton.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2021-06-07T22:12:41.000Z","updated_at":"2024-08-02T00:29:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"ea86d52c-8f82-4d11-a835-b8c5700fb92a","html_url":"https://github.com/kripton/rp2040-compressiontest","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kripton%2Frp2040-compressiontest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kripton%2Frp2040-compressiontest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kripton%2Frp2040-compressiontest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kripton%2Frp2040-compressiontest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kripton","download_url":"https://codeload.github.com/kripton/rp2040-compressiontest/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234129026,"owners_count":18784155,"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":[],"created_at":"2024-11-15T12:28:23.702Z","updated_at":"2025-09-24T21:30:59.098Z","avatar_url":"https://github.com/kripton.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rp2040-compressiontest: Benchmark of different compression algorithms on the rp2040\n\n## Why I did this\n\nI am currently coding an open-source multi-universe USB-DMX512-interface \n(https://github.com/OpenLightingProject/rp2040-dongle). DMX512 has the advantage \nthat unused channels (and there are usually plenty of them just have the value \nof 0. That makes the amount of data shrink by a large amount if compressed.\n\nOf course, the rp2040 is an \"embedded\" processor, so it's not the fastest \nthing to run code and memory is also pretty limited. So what to do if there are \nplenty compression algorithms out there to choose from? Benchmark them :)\n\nPlease be aware that my use case is pretty limited and constrained: I'm \"only\" \ncompressing 512 byte each and I want to do so FAST (no longer than 2ms). Your \nuse case and requirements might be hugely different.\n\n## For the impatient: Here are my results (CPU overclocked to 250MHz)\n```\nWelcome to rp2040-compressiontest\npll_sys  = 250001kHz (= ~250MHz)\n\nInitializing test vectors ... 495µs\n8 test vectors:\n        ALL_ZERO\n        ALL_ONE\n        SAWTOOTH_SMALL\n        SAWTOOTH_MEDIUM\n        SAWTOOTH_LARGE\n        ALL_RANDOM\n        ALTERNATING_RANDOM_ZERO\n        BLOCKS_8RANDOM_8ZERO\n\nInitializing compression algorithms ... 95µs\n5 compression algorithms:\n        HEATSHRINK\n        ZLIB\n        ZSTD\n        SNAPPY\n        BROTLI\n\nBENCHMARK RUN START\n\nHEATSHRINK:\n        ALL_ZERO:                        Runtime:   268µs;      Insize: 512;    Outsize:  16,   Ratio:   3%     Decompress time:   151µs        Verification: PASSED\n        ALL_ONE:                         Runtime:   236µs;      Insize: 512;    Outsize:  18,   Ratio:   3%     Decompress time:   131µs        Verification: PASSED\n        SAWTOOTH_SMALL:                  Runtime:   257µs;      Insize: 512;    Outsize:  19,   Ratio:   3%     Decompress time:   123µs        Verification: PASSED\n        SAWTOOTH_MEDIUM:                 Runtime:   281µs;      Insize: 512;    Outsize:  34,   Ratio:   6%     Decompress time:   141µs        Verification: PASSED\n        SAWTOOTH_LARGE:                  Runtime:   382µs;      Insize: 512;    Outsize:  86,   Ratio:  16%     Decompress time:   205µs        Verification: PASSED\n        ALL_RANDOM:                      Runtime:  1193µs;      Insize: 512;    Outsize: 576,   Ratio: 112%     Decompress time:   824µs        Verification: PASSED\n        ALTERNATING_RANDOM_ZERO:         Runtime:  8384µs;      Insize: 512;    Outsize: 479,   Ratio:  93%     Decompress time:   747µs        Verification: PASSED\n        BLOCKS_8RANDOM_8ZERO:            Runtime:  2109µs;      Insize: 512;    Outsize: 348,   Ratio:  67%     Decompress time:   563µs        Verification: PASSED\nZLIB:\n        ALL_ZERO:                        Runtime:   670µs;      Insize: 512;    Outsize:  14,   Ratio:   2%     Decompress time:   166µs        Verification: PASSED\n        ALL_ONE:                         Runtime:   537µs;      Insize: 512;    Outsize:  14,   Ratio:   2%     Decompress time:   100µs        Verification: PASSED\n        SAWTOOTH_SMALL:                  Runtime:   514µs;      Insize: 512;    Outsize:  15,   Ratio:   2%     Decompress time:    94µs        Verification: PASSED\n        SAWTOOTH_MEDIUM:                 Runtime:   569µs;      Insize: 512;    Outsize:  30,   Ratio:   5%     Decompress time:   103µs        Verification: PASSED\n        SAWTOOTH_LARGE:                  Runtime:   806µs;      Insize: 512;    Outsize:  81,   Ratio:  15%     Decompress time:   130µs        Verification: PASSED\n        ALL_RANDOM:                      Runtime:  2042µs;      Insize: 512;    Outsize: 523,   Ratio: 102%     Decompress time:    86µs        Verification: PASSED\n        ALTERNATING_RANDOM_ZERO:         Runtime:  1994µs;      Insize: 512;    Outsize: 393,   Ratio:  76%     Decompress time:   501µs        Verification: PASSED\n        BLOCKS_8RANDOM_8ZERO:            Runtime:  1877µs;      Insize: 512;    Outsize: 331,   Ratio:  64%     Decompress time:   227µs        Verification: PASSED\nZSTD:\n        ALL_ZERO:                        Runtime:   610µs;      Insize: 512;    Outsize:  19,   Ratio:   3%     Decompress time:   307µs        Verification: PASSED\n        ALL_ONE:                         Runtime:   508µs;      Insize: 512;    Outsize:  19,   Ratio:   3%     Decompress time:   139µs        Verification: PASSED\n        SAWTOOTH_SMALL:                  Runtime:   472µs;      Insize: 512;    Outsize:  19,   Ratio:   3%     Decompress time:   130µs        Verification: PASSED\n        SAWTOOTH_MEDIUM:                 Runtime:   466µs;      Insize: 512;    Outsize:  33,   Ratio:   6%     Decompress time:   117µs        Verification: PASSED\n        SAWTOOTH_LARGE:                  Runtime:   543µs;      Insize: 512;    Outsize:  83,   Ratio:  16%     Decompress time:   128µs        Verification: PASSED\n        ALL_RANDOM:                      Runtime:   578µs;      Insize: 512;    Outsize: 522,   Ratio: 101%     Decompress time:    63µs        Verification: PASSED\n        ALTERNATING_RANDOM_ZERO:         Runtime:  1422µs;      Insize: 512;    Outsize: 379,   Ratio:  74%     Decompress time:   654µs        Verification: PASSED\n        BLOCKS_8RANDOM_8ZERO:            Runtime:  1822µs;      Insize: 512;    Outsize: 345,   Ratio:  67%     Decompress time:   235µs        Verification: PASSED\nSNAPPY:\n        ALL_ZERO:                        Runtime:   191µs;      Insize: 512;    Outsize:  28,   Ratio:   5%     Decompress time:   235µs        Verification: PASSED\n        ALL_ONE:                         Runtime:   128µs;      Insize: 512;    Outsize:  28,   Ratio:   5%     Decompress time:   103µs        Verification: PASSED\n        SAWTOOTH_SMALL:                  Runtime:   122µs;      Insize: 512;    Outsize:  29,   Ratio:   5%     Decompress time:    99µs        Verification: PASSED\n        SAWTOOTH_MEDIUM:                 Runtime:   120µs;      Insize: 512;    Outsize:  43,   Ratio:   8%     Decompress time:    75µs        Verification: PASSED\n        SAWTOOTH_LARGE:                  Runtime:   133µs;      Insize: 512;    Outsize:  90,   Ratio:  17%     Decompress time:    58µs        Verification: PASSED\n        ALL_RANDOM:                      Runtime:    74µs;      Insize: 512;    Outsize: 517,   Ratio: 100%     Decompress time:    46µs        Verification: PASSED\n        ALTERNATING_RANDOM_ZERO:         Runtime:    76µs;      Insize: 512;    Outsize: 517,   Ratio: 100%     Decompress time:    34µs        Verification: PASSED\n        BLOCKS_8RANDOM_8ZERO:            Runtime:   249µs;      Insize: 512;    Outsize: 359,   Ratio:  70%     Decompress time:   243µs        Verification: PASSED\nBROTLI:\n        ALL_ZERO:                        Runtime:   733µs;      Insize: 512;    Outsize:  20,   Ratio:   3%     Decompress time:   568µs        Verification: PASSED\n        ALL_ONE:                         Runtime:   594µs;      Insize: 512;    Outsize:  20,   Ratio:   3%     Decompress time:   536µs        Verification: PASSED\n        SAWTOOTH_SMALL:                  Runtime:   679µs;      Insize: 512;    Outsize:  21,   Ratio:   4%     Decompress time:   408µs        Verification: PASSED\n        SAWTOOTH_MEDIUM:                 Runtime:   841µs;      Insize: 512;    Outsize:  67,   Ratio:  13%     Decompress time:   438µs        Verification: PASSED\n        SAWTOOTH_LARGE:                  Runtime:  1086µs;      Insize: 512;    Outsize: 162,   Ratio:  31%     Decompress time:   531µs        Verification: PASSED\n        ALL_RANDOM:                      Runtime:  2412µs;      Insize: 512;    Outsize: 516,   Ratio: 100%     Decompress time:   134µs        Verification: PASSED\n        ALTERNATING_RANDOM_ZERO:         Runtime:  2168µs;      Insize: 512;    Outsize: 427,   Ratio:  83%     Decompress time:   827µs        Verification: PASSED\n        BLOCKS_8RANDOM_8ZERO:            Runtime:  2027µs;      Insize: 512;    Outsize: 410,   Ratio:  80%     Decompress time:   881µs        Verification: PASSED\n```\n\n\n## Building from source\n\nThis project uses the usual toolchain for the RP2040-based projects. You will \nneed a (cross-)compiler for the ARM Cortex M0 and the pico-sdk. For details \nhow you can achieve this on your system, please refer to\nhttps://datasheets.raspberrypi.org/pico/getting-started-with-pico.pdf\n\nBasically, once all requirements are met, run:\n```\nmkdir build\ncd build\ncmake ../src\nmake\n```\nThis should result in a file called `rp2040-compressiontest.uf2` that can be copied to the Pico when it's in bootloader-mode.\n\n## License\n\nThis source code, schematics and board layouts is licensed under the GPL.\n\nParts taken and modified from TinyUSB (`tusb_config.h`, `usb_descriptors.c`) is:\n\n     * The MIT License (MIT)\n     * Copyright (c) 2019 Ha Thach (tinyusb.org)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkripton%2Frp2040-compressiontest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkripton%2Frp2040-compressiontest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkripton%2Frp2040-compressiontest/lists"}