{"id":26558209,"url":"https://github.com/simpson-computer-technologies-research/requests","last_synced_at":"2025-03-22T12:33:34.303Z","repository":{"id":61121885,"uuid":"547571880","full_name":"Simpson-Computer-Technologies-Research/Requests","owner":"Simpson-Computer-Technologies-Research","description":"Which is faster? Sending http requests in Go, Python or Rust?","archived":false,"fork":false,"pushed_at":"2022-10-09T18:18:59.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2023-03-26T13:19:54.084Z","etag":null,"topics":["go","http","python","requests","rust","speed"],"latest_commit_sha":null,"homepage":"https://simpson-computer-technologies-research.github.io/Requests/","language":"Go","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/Simpson-Computer-Technologies-Research.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}},"created_at":"2022-10-07T23:08:36.000Z","updated_at":"2022-10-09T18:18:19.000Z","dependencies_parsed_at":"2022-10-11T07:37:52.616Z","dependency_job_id":null,"html_url":"https://github.com/Simpson-Computer-Technologies-Research/Requests","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Simpson-Computer-Technologies-Research%2FRequests","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Simpson-Computer-Technologies-Research%2FRequests/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Simpson-Computer-Technologies-Research%2FRequests/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Simpson-Computer-Technologies-Research%2FRequests/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Simpson-Computer-Technologies-Research","download_url":"https://codeload.github.com/Simpson-Computer-Technologies-Research/Requests/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244959409,"owners_count":20538625,"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":["go","http","python","requests","rust","speed"],"created_at":"2025-03-22T12:31:29.562Z","updated_at":"2025-03-22T12:33:34.296Z","avatar_url":"https://github.com/Simpson-Computer-Technologies-Research.png","language":"Go","readme":"# Requests ![Stars](https://img.shields.io/github/stars/Simpson-Computer-Technologies-Research/Requests?color=brightgreen) ![Watchers](https://img.shields.io/github/watchers/Simpson-Computer-Technologies-Research/Requests?label=Watchers)\n![banner (1)](https://user-images.githubusercontent.com/75189508/194771973-dec86e5e-ac0c-4dea-a8cb-3f48514c2709.png)\nWhich is faster? Sending http requests in Go, Python or Rust?\n\n# Benchmarks\n\n```rust\n\n// Python\nGET:  \t\tAverage Result: 64.0871ms\nPOST: \t\tAverage Result: 64.0461ms\nPUT:  \t\tAverage Result: 64.4185ms\nTHREADED: \tAverage Result: 6.28s\n\n// Golang\nGET:  \t\tAverage Result: 57.3495ms\nPOST: \t\tAverage Result: 59.2759ms\nPUT:  \t\tAverage Result: 57.793ms\nGOROUTINES: \tAverage Result: 289.2099ms\n\n// Rust\nGET/PUT/POST: \tAverage Result: 183ms\nTHREADED:\tUndetermined\n\n```\n\n# Functions\n\n\u003ch3\u003ePython\u003c/h3\u003e\n\n```py\n\nrequests.get(\"http://httpbin.org/get\")\nrequests.post(\"http://httpbin.org/get\")\nrequests.put(\"http://httpbin.org/get\")\n\n# // Send http request function\ndef main():\n    requests.get(\"http://httpbin.org/get\")\n\n# // Create new threads and start them\nfor _ in range(100):\n    threading.Thread(target=main()).start()\n\n```\n\n\u003ch3\u003eRust\u003c/h3\u003e\n\n```rust\n#[tokio::main]\nasync fn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    let request = reqwest::get(\"https://httpbin.org/get\");\n\n    // Store the start time of the request\n    let start: u128 = SystemTime::now()\n        .duration_since(UNIX_EPOCH)\n        .unwrap()\n        .as_millis();\n\n    // Send the HTTP GET Request\n    request.await?;\n\n    // Store the end time of the request\n    let end: u128 = SystemTime::now()\n        .duration_since(UNIX_EPOCH)\n        .unwrap()\n        .as_millis();\n\n    // Print the time it took to send the http request\n    // Average Result: 183ms\n    println!(\"{}ms\", end-start);\n\n    // Return Success\n    return Ok(())\n}\n```\n\n\n\u003ch3\u003eGo\u003c/h3\u003e\n\n```go\n// Main Function\nfunc main() {\n\tvar client *http.Client = \u0026http.Client{}\n\n\tGET(client)  // Average Result: 57.3495ms\n\tPOST(client) // Average Result: 59.2759ms\n\tPUT(client)  // Average Result: 57.793ms\n\n\t// Sending 100 HTTP GET Requests\n\t// Average Result: 289.2099ms\n\tGET_USING_GOROUTINES(client)\n}\n\n// Sending an HTTP GET Request\nfunc GET(client *http.Client) {\n\t// Check out https://github.com/Simpson-Computer-Technologies-Research/DeclarationSpeeds\n\t// To see why you should use 'var ... type' instead of ':='\n\tvar (\n\t\tstartTime time.Time = time.Now()\n\t\treq, _              = http.NewRequest(\"GET\", \"http://httpbin.org/get\", bytes.NewBuffer([]byte{}))\n\t)\n\tclient.Do(req)\n\tfmt.Println(time.Since(startTime))\n}\n\n// Sending an HTTP POST Request\nfunc POST(client *http.Client) {\n\tvar (\n\t\tstartTime time.Time = time.Now()\n\t\treq, _              = http.NewRequest(\"POST\", \"http://httpbin.org/post\", bytes.NewBuffer([]byte{}))\n\t)\n\tclient.Do(req)\n\tfmt.Println(time.Since(startTime))\n}\n\n// Sending an HTTP PUT Request\nfunc PUT(client *http.Client) {\n\t// set the HTTP method, url, and request body\n\tvar (\n\t\tstartTime time.Time = time.Now()\n\t\treq, _              = http.NewRequest(\"PUT\", \"http://httpbin.org/put\", bytes.NewBuffer([]byte{}))\n\t)\n\tclient.Do(req)\n\tfmt.Println(time.Since(startTime))\n}\n\n// Sending an HTTP GET Request\nfunc GET_USING_GOROUTINES(client *http.Client) {\n\t// Check out https://github.com/Simpson-Computer-Technologies-Research/DeclarationSpeeds\n\t// To see why you should use 'var ... type' instead of ':='\n\tvar (\n\t\tstartTime time.Time       = time.Now()\n\t\twg        *sync.WaitGroup = \u0026sync.WaitGroup{}\n\t)\n\n\t// Starting 100 Goroutines\n\tfor i := 0; i \u003c 100; i++ {\n\t\twg.Add(1)\n\n\t\t// The goroutine\n\t\tgo func() {\n\t\t\tdefer wg.Done()\n\t\t\tvar req, _ = http.NewRequest(\"GET\", \"http://httpbin.org/get\", bytes.NewBuffer([]byte{}))\n\t\t\tclient.Do(req)\n\t\t}()\n\t}\n\n\t// Wait for all goroutines to finish before\n\t// Printing the time it took\n\twg.Wait()\n\tfmt.Println(time.Since(startTime))\n}\n```\n\n\n# License\nMIT License\n\nCopyright (c) 2022 Tristan Simpson\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimpson-computer-technologies-research%2Frequests","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimpson-computer-technologies-research%2Frequests","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimpson-computer-technologies-research%2Frequests/lists"}