-
Notifications
You must be signed in to change notification settings - Fork 95
Open
Description
I tried to compare the work of the coroutines in golang and "may" library, using the example of simple code that does almost nothing except run these coroutines
In go
package main
import (
"sync"
"time"
)
func main() {
var wg sync.WaitGroup
start := time.Now();
for i := 0; i <= 10000000; i++ {
wg.Add(1);
go func() {
wg.Done()
}()
}
wg.Wait()
finish := time.Now();
elapsed := finish.Sub(start)
println(elapsed.Seconds())
}
and it take about 3-4 sec
but if i run this
#[macro_use]
extern crate may;
use std::time::{Instant};
use wg::WaitGroup;
fn main() {
let wg = WaitGroup::new();
let now = Instant::now();
for _ in 0..10_000_000 {
let co_wg = wg.add(1);
go!(move || {
co_wg.done();
});
}
wg.wait();
println!("{}", now.elapsed().as_secs());
}
it take about 60+ sec
maybe I don't understand something or "may" is not designed to run millions coroutines at one time
Metadata
Metadata
Assignees
Labels
No labels