Skip to content

Tests using the asynchronous save to file method

Notifications You must be signed in to change notification settings

Mirocow/test-threads

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tests using the asynchronous save to file method

$test = function ($lead){
    sleep(2);
    file_put_contents(LOG_FILE_PATH, implode('|', [$lead->id, $lead->categoryName, time()]) . "\n", FILE_APPEND);
    return true;
};

$commands = \tests\Commands::getInstance();
$commands->threads = 500;
$commands->count = 10000;
$commands->add(new \tests\commands\PcntlComponentCommand($test));
$commands->add(new \tests\commands\SwooleComponentCommand($test));
$commands->add(new \tests\commands\NoThreadsComponentCommand($test)); // only 1 thread
$commands->runTests($event);

Tests

  • threads
  • parallel
  • swoole - done
  • pcntl - done
  • popen
  • proc_open
  • queue

Run

$ cd docker
$ docker-compose up -d
$ docker-compose php php test.php

Begin tests 10000 leads write with threads: 500
Test class tests\commands\PcntlComponentCommand  it`s took 0.8094783504804 min.
Test class tests\commands\SwooleComponentCommand  it`s took 2.934555431207 min.