// BaseContinuationImpl publicfinaloverridefunresumeWith(result: Result<Any?>) { // This loop unrolls recursion in current.resumeWith(param) to make saner and shorter stack traces on resume var current = this var param = result while (true) { // Invoke "resume" debug probe on every resumed continuation, so that a debugging library infrastructure // can precisely track what part of suspended callstack was already resumed probeCoroutineResumed(current) with(current) { val completion = completion!! // fail fast when trying to resume continuation without completion val outcome: Result<Any?> = try { // 调用上面反编译代码的 invokeSuspend 函数 val outcome = invokeSuspend(param) if (outcome === COROUTINE_SUSPENDED) return Result.success(outcome) } catch (exception: Throwable) { Result.failure(exception) } releaseIntercepted() // this state machine instance is terminating if (completion is BaseContinuationImpl) { // unrolling recursion via loop current = completion param = outcome } else { // top-level completion reached -- invoke and return completion.resumeWith(outcome) return } } } }
Concurrency Level: 100 Time taken for tests: 13.406 seconds Complete requests: 10000 Failed requests: 0 Keep-Alive requests: 10000 Total transferred: 650000 bytes HTML transferred: 30000 bytes Requests per second: 745.94 [#/sec] (mean) Time per request: 134.058 [ms] (mean) Time per request: 1.341 [ms] (mean, across all concurrent requests) Transfer rate: 47.35 [Kbytes/sec] received
Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 2.4 0 28 Processing: 106 132 13.0 129 199 Waiting: 106 132 13.0 129 199 Total: 106 132 13.7 129 199
Percentage of the requests served within a certain time (ms) 50% 129 66% 134 75% 139 80% 142 90% 150 95% 156 98% 167 99% 186 100% 199 (longest request)
Concurrency Level: 100 Time taken for tests: 45.134 seconds Complete requests: 10000 Failed requests: 17 (Connect: 0, Receive: 0, Length: 17, Exceptions: 0) Non-2xx responses: 17 Keep-Alive requests: 9960 Total transferred: 1649167 bytes HTML transferred: 39078 bytes Requests per second: 221.56 [#/sec] (mean) Time per request: 451.336 [ms] (mean) Time per request: 4.513 [ms] (mean, across all concurrent requests) Transfer rate: 35.68 [Kbytes/sec] received
Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 3.4 0 39 Processing: 116 421 2375.9 177 26593 Waiting: 116 421 2375.9 177 26593 Total: 116 421 2375.9 177 26593
Percentage of the requests served within a certain time (ms) 50% 177 66% 187 75% 194 80% 198 90% 210 95% 223 98% 246 99% 13434 100% 26593 (longest request)