1
0
Fork 0

Add extra logging before and after SAT solving

pull/5108/head
Niels Keurentjes 2016-03-24 23:19:40 +01:00
parent 0a8528c5c7
commit 8e78ce9a43
3 changed files with 14 additions and 4 deletions

View File

@ -12,6 +12,7 @@
namespace Composer\DependencyResolver;
use Composer\IO\IOInterface;
use Composer\Repository\RepositoryInterface;
use Composer\Repository\PlatformRepository;
@ -56,13 +57,18 @@ class Solver
/** @var array */
protected $learnedWhy = array();
/** @var IOInterface */
protected $io;
/**
* @param PolicyInterface $policy
* @param Pool $pool
* @param RepositoryInterface $installed
* @param IOInterface $io
*/
public function __construct(PolicyInterface $policy, Pool $pool, RepositoryInterface $installed)
public function __construct(PolicyInterface $policy, Pool $pool, RepositoryInterface $installed, IOInterface $io)
{
$this->io = $io;
$this->policy = $policy;
$this->pool = $pool;
$this->installed = $installed;
@ -217,7 +223,10 @@ class Solver
/* make decisions based on job/update assertions */
$this->makeAssertionRuleDecisions();
$this->io->writeError('Resolving dependencies through SAT', true, IOInterface::DEBUG);
$before = microtime(true);
$this->runSat(true);
$this->io->writeError(sprintf('Dependency resolution completed in %.3f seconds', microtime(true) - $before), true, IOInterface::VERBOSE);
// decide to remove everything that's installed and undecided
foreach ($this->installedMap as $packageId => $void) {

View File

@ -287,7 +287,7 @@ class Installer
}
$this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::PRE_DEPENDENCIES_SOLVING, false, $policy, $pool, $installedRepo, $request);
$solver = new Solver($policy, $pool, $installedRepo);
$solver = new Solver($policy, $pool, $installedRepo, $this->io);
$ops = $solver->solve($request, $this->ignorePlatformReqs);
$this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::POST_DEPENDENCIES_SOLVING, false, $policy, $pool, $installedRepo, $request, $ops);
foreach ($ops as $op) {
@ -493,7 +493,7 @@ class Installer
// solve dependencies
$this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::PRE_DEPENDENCIES_SOLVING, $this->devMode, $policy, $pool, $installedRepo, $request);
$solver = new Solver($policy, $pool, $installedRepo);
$solver = new Solver($policy, $pool, $installedRepo, $this->io);
try {
$operations = $solver->solve($request, $this->ignorePlatformReqs);
$this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::POST_DEPENDENCIES_SOLVING, $this->devMode, $policy, $pool, $installedRepo, $request, $operations);

View File

@ -12,6 +12,7 @@
namespace Composer\Test\DependencyResolver;
use Composer\IO\NullIO;
use Composer\Repository\ArrayRepository;
use Composer\DependencyResolver\DefaultPolicy;
use Composer\DependencyResolver\Pool;
@ -38,7 +39,7 @@ class SolverTest extends TestCase
$this->request = new Request($this->pool);
$this->policy = new DefaultPolicy;
$this->solver = new Solver($this->policy, $this->pool, $this->repoInstalled);
$this->solver = new Solver($this->policy, $this->pool, $this->repoInstalled, new NullIO());
}
public function testSolverInstallSingle()