package main
import (
"fmt"
"sync"
"time"
)
func main() {
wg := &sync.WaitGroup{}
wg.Add(1)
start := time.Now()
go func() {
defer wg.Done()
for i := 0; i < 5000000; i++ {
time.Sleep(time.Millisecond * 1)
}
}()
wg.Wait()
fmt.Println("Time taken: ", time.Since(start))
}
<?php
declare(ticks=1);
require_once __DIR__ . '/../../../vendor/autoload.php';
use vennv\vapm\CoroutineGen;
use vennv\vapm\System;
System::time();
function coroutineA()
{
for ($i = 0; $i < 5000000; $i++) {
yield CoroutineGen::delay(1);
}
System::timeEnd();
}
CoroutineGen::runNonBlocking(coroutineA());