{"id":21188163,"url":"https://github.com/dev1an/swift-nodejs-udp-benchmark","last_synced_at":"2026-05-08T15:37:45.674Z","repository":{"id":90135143,"uuid":"136036314","full_name":"Dev1an/Swift-NodeJS-UDP-Benchmark","owner":"Dev1an","description":"Benchmark UDP throughput. Swift-NIO vs nodesJS \"dgram\"","archived":false,"fork":false,"pushed_at":"2018-06-05T09:55:22.000Z","size":101,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-14T20:31:33.663Z","etag":null,"topics":["benchmark","datagram","javascript","networking","nodejs","swift","udp"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Dev1an.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2018-06-04T14:21:18.000Z","updated_at":"2022-06-27T15:02:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"2823c5ab-fa3e-41f8-a068-ae844c7e6e11","html_url":"https://github.com/Dev1an/Swift-NodeJS-UDP-Benchmark","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Dev1an/Swift-NodeJS-UDP-Benchmark","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dev1an%2FSwift-NodeJS-UDP-Benchmark","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dev1an%2FSwift-NodeJS-UDP-Benchmark/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dev1an%2FSwift-NodeJS-UDP-Benchmark/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dev1an%2FSwift-NodeJS-UDP-Benchmark/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Dev1an","download_url":"https://codeload.github.com/Dev1an/Swift-NodeJS-UDP-Benchmark/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dev1an%2FSwift-NodeJS-UDP-Benchmark/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262030331,"owners_count":23247630,"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":["benchmark","datagram","javascript","networking","nodejs","swift","udp"],"created_at":"2024-11-20T18:42:51.976Z","updated_at":"2026-05-08T15:37:45.643Z","avatar_url":"https://github.com/Dev1an.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Comparing UDP throughput\n\nThis is a benchmark that compares the performance of the same UDP application written in\n\n- **Swift** using the [NIO networking library](https://github.com/apple/swift-nio)\n- **Javascript** using the `\"dgram\"` [module](https://nodejs.org/dist/latest-v8.x/docs/api/dgram.html) of **NodeJS**\n\n## The application\n\n1. Opens two different UDP (IPv4) sockets on the loopback interface\n2. Sends the numbers 0x0000 to 0xFFFF from one socket to the another. This is done in an interleaved way. When a socket receives a number it increments it and sends the result back to the originating socket. This process is bootstrapped by one socket sending number 0 to the other socket. The sockets then increment the number while sending it back and forth. When the number 0xFFFF is reached the application stops. It goes as follows:\n   - socket A sends number 0 to socket B\n   - when socket B receives 0, it increments it and sends number 1 to socket A\n   - when socket A receives 1, it increments it and sends number 2 to socket B\n   - when socket B receives 2, it increments it and sends number 3 to socket A\n   - ...\n\n   The numbers are encoded and decoded as unsigned 16 bit integers.\n\n## The result\n\nI ran the applications on both my Macbook and a Raspberry Pi 3 Model B. The resulting execution times are plotted in the diagram below. Although the same amount of bytes are sent over the UDP sockets, it is clear that swift is able to transfer them (about 1.47 times) faster.\n\n![results](https://dev1an.github.io/Swift-NodeJS-UDP-Benchmark/results.svg)\n\n\u003cp align=\"center\"\u003eExecution time in milliseconds\u003c/p\u003e\n\n## Run it yourself\n\n**Requirements**\n\n- Swift 4.1\n- NodeJS\n- git\n- awk\n\n**Usage**\n\n```sh\n# Shell\ngit clone https://github.com/Dev1an/Swift-NodeJS-UDP-Benchmark.git\ncd Swift-NodeJS-UDP-Benchmark\nscripts/benchmark.sh\n```\n\nThis script will show you the execution time of both application implementations and save it anonymously on my mlab database.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdev1an%2Fswift-nodejs-udp-benchmark","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdev1an%2Fswift-nodejs-udp-benchmark","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdev1an%2Fswift-nodejs-udp-benchmark/lists"}