You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import SwiftUI
import Swifter
@main
struct MacInputServer: App {
let server: HttpServer;
var body: some Scene {
WindowGroup {
ContentView()
}
}
func sleep(req: HttpRequest) -> HttpResponse {
usleep(100_000);
return .ok(.text(""))
}
init() {
server = HttpServer()
server["/sleep"] = sleep
try! server.start(999, forceIPv4: true, priority: DispatchQoS.QoSClass.userInteractive);
}
}
I'm running while true; do time curl localhost:999/sleep; done to test it. The first ~100 requests finish in about 120ms as expected. But after that it starts hanging for up to 10 seconds:
curl localhost:999/sleep 0.01s user 0.01s system 11% cpu 0.118 total
curl localhost:999/sleep 0.01s user 0.01s system 0% cpu 10.121 total
curl localhost:999/sleep 0.01s user 0.01s system 0% cpu 5.134 total
curl localhost:999/sleep 0.00s user 0.01s system 0% cpu 5.902 total
If I just sleep in a loop, the performance stays consistent, so this is definitely the fault of Swifter. How can this be fixed?
The text was updated successfully, but these errors were encountered:
I have the following server:
I'm running
while true; do time curl localhost:999/sleep; done
to test it. The first ~100 requests finish in about 120ms as expected. But after that it starts hanging for up to 10 seconds:If I just sleep in a loop, the performance stays consistent, so this is definitely the fault of Swifter. How can this be fixed?
The text was updated successfully, but these errors were encountered: