Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about coroutine #103

Open
MoJI4yH opened this issue May 21, 2023 · 7 comments
Open

Question about coroutine #103

MoJI4yH opened this issue May 21, 2023 · 7 comments

Comments

@MoJI4yH
Copy link

MoJI4yH commented May 21, 2023

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

@MoJI4yH MoJI4yH changed the title Question about corutine Question about coroutine May 21, 2023
@Xudong-Huang
Copy link
Owner

Xudong-Huang commented May 27, 2023 via email

@Xudong-Huang
Copy link
Owner

I would support may::sync::WaitGroup and may::sync::Barrier in future release

@hkhk368
Copy link

hkhk368 commented Dec 22, 2024

I would support may::sync::WaitGroup and may::sync::Barrier in future release

I would like to know, when will we get may::sync::WaitGroup? Thanks.

@Xudong-Huang
Copy link
Owner

Ah, I forgot this task! It should not that hard to implement.

@hkhk368
Copy link

hkhk368 commented Dec 24, 2024

Ah, I forgot this task! It should not that hard to implement.

Thank you for your prompt reply. I see that you are already working on the new feature, such as waitgroup. I really appreciate it. Please notify me once you have completed it. I look forward to using the new version with waitgroup as soon as possible. Thank you.

@Xudong-Huang
Copy link
Owner

just release 0.3.48

@hkhk368
Copy link

hkhk368 commented Dec 24, 2024

just release 0.3.48

Thank you very much for your help. I wish you a pleasant day!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants