Closed gohryt closed 4 months ago
If your whole evaluation is speed, and not the multi other aspects/features provided, I take you pretty new to the field. You will need to preform other tasks once the switch is executed.
Not sure what's your use case, the switching here is to an scheduler, the coroutine task is queued up for one. The behavior here is as in GoLang.
What library you have in mine besides another programming language altogether? The ones I mention in the README.md, surly doesn't do the things this library does.
So the benchmarks will need to do other things after the switch, perform a lot of resource management, and there you will find that's not the concern of the Author of those libraries, it's the responsibility of user of the library to figure out.
That can be provided once your provide the script to run, the coroutine libraries to compare to that is performing benchmarks already.
For future reference, there is https://pkolaczk.github.io/memory-consumption-of-async/ that has benchmarks comparing languages async speed. I find theres another problem with other plain C coroutine libraries, and that's ease of use.
#include "coroutine.h"
void *func(void *arg) {
co_sleep(10 * time_Second);
return 0;
}
int co_main(int argc, char **argv) {
int numRoutines = 100000, i;
if (argc > 1)
numRoutines = atoi(argv[1]);
wait_group_t *wg = co_wait_group();
for (i = 1; i <= numRoutines; i++) {
co_go(func, NULL);
}
co_wait(wg);
printf("All coroutines finished.\n");
return 0;
}
The above script is based off GoLang version at https://github.com/pkolaczk/async-runtimes-benchmarks/blob/main/go/main.go and below, the thing about Go's version, not sure if it's all single threaded.
The script I present is all single threaded currently, this library multi-thread featured not actually running coroutines in them. The feature not fully implemented nor tested in any way. The logic is only in place for so. Currently, Libuv integration is handling most I/O aspects.
You could request to have the above script included in the benchmarks, noting this library's current state.
package main
import (
"fmt"
"os"
"strconv"
"sync"
"time"
)
func main() {
numRoutines := 100000
if len(os.Args) > 1 {
n, err := strconv.Atoi(os.Args[1])
if err == nil {
numRoutines = n
}
}
var wg sync.WaitGroup
for i := 0; i < numRoutines; i++ {
wg.Add(1)
go func() {
defer wg.Done()
time.Sleep(10 * time.Second)
}()
}
wg.Wait()
fmt.Println("All goroutines finished.")
}
It wll be simplier when presenting it to somebody for chosing between