3v4l.org

run code in 300+ PHP versions simultaneously
<?php define( 'TERM_RATES_BY_YEAR', [ 2001 => ['term' => 24, 'rates' => [15.90, 19.90, 22.90, 22.90, 22.90]], 2002 => ['term' => 24, 'rates' => [15.90, 19.90, 22.90, 22.90, 22.90]], 2003 => ['term' => 24, 'rates' => [15.90, 19.90, 22.90, 22.90, 22.90]], 2004 => ['term' => 24, 'rates' => [15.90, 19.90, 22.90, 22.90, 22.90]], 2005 => ['term' => 24, 'rates' => [15.90, 19.90, 22.90, 22.90, 22.90]], 2006 => ['term' => 24, 'rates' => [15.90, 18.90, 21.90, 22.90, 22.90]], 2007 => ['term' => 36, 'rates' => [15.90, 18.90, 21.90, 22.90, 22.90]], 2008 => ['term' => 36, 'rates' => [14.90, 17.90, 21.90, 22.90, 22.90]], 2009 => ['term' => 36, 'rates' => [14.90, 17.90, 20.90, 20.90, 20.90]], 2010 => ['term' => 36, 'rates' => [14.90, 17.90, 20.90, 20.90, 20.90]], 2011 => ['term' => 42, 'rates' => [14.90, 16.90, 19.90, 19.90, 20.90]], 2012 => ['term' => 42, 'rates' => [12.90, 15.90, 18.90, 19.90, 19.90]], 2013 => ['term' => 42, 'rates' => [12.90, 15.90, 18.90, 18.90, 18.90]], 2014 => ['term' => 48, 'rates' => [11.90, 14.90, 17.90, 18.90, 18.90]], ] ); define('CREDIT_SCORE_MINIMUM_THRESHOLDS', [720, 610, 580, 530, 489]); /** @throws Exception */ function getRateIndexFromCreditScore(int $creditScore): ?int { foreach (CREDIT_SCORE_MINIMUM_THRESHOLDS as $rateIndex => $minThreshold) { if ($creditScore >= $minThreshold) { return $rateIndex; } } throw new Exception("Sorry, your credit score ($creditScore) does not qualify for financing"); } foreach (range(2000, 2015) as $year) { try { if (!isset(TERM_RATES_BY_YEAR[$year])) { throw new Exception("Sorry, your vehicle year ($year) does not qualify for financing"); } $score = rand(300, 850); $rateIndex = getRateIndexFromCreditScore($score); $outcome = sprintf( 'Vehicle Year: %d, Credit Score: %d, Term: %d, Rate: %.2f', $year, $score, TERM_RATES_BY_YEAR[$year]['term'], TERM_RATES_BY_YEAR[$year]['rates'][$rateIndex] ); } catch (Exception $e) { $outcome = $e->getMessage(); } echo "$outcome\n"; }

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.0.120.0080.00513.34
8.0.110.0070.00713.34
8.0.100.0040.00813.43
8.0.90.0130.00013.37
8.0.80.0130.00013.37
8.0.70.0060.00613.41
8.0.60.0080.00413.28
8.0.50.0130.00013.32
8.0.30.0120.00013.32
8.0.20.0090.00313.45
8.0.10.0040.00813.43
8.0.00.0130.00013.43
7.4.250.0100.00513.29
7.4.240.0110.00313.34
7.4.230.0100.00513.30
7.4.220.0110.00013.29
7.4.210.0000.01113.23
7.4.200.0120.00013.39
7.4.190.0120.00013.28
7.4.180.0100.00313.33
7.4.160.0120.00013.31
7.4.150.0080.00613.18
7.4.140.0060.00613.22
7.4.130.0060.00613.20
7.4.120.0060.00613.12
7.4.110.0060.00613.25
7.4.100.0060.00613.20
7.4.90.0060.00613.23
7.4.80.0100.00213.21
7.4.70.0100.00213.15
7.4.60.0120.00013.26
7.4.50.0090.00513.26
7.4.40.0080.00413.14
7.4.30.0050.00713.20
7.4.20.0120.00013.25
7.4.10.0100.00213.13
7.4.00.0110.00013.22
7.3.310.0120.00013.41
7.3.300.0090.00313.20
7.3.290.0000.01213.27
7.3.280.0060.00613.43
7.3.270.0090.00413.28
7.3.260.0050.00913.40
7.3.250.0080.00413.38
7.3.240.0120.00013.46
7.3.230.0000.01313.15
7.3.220.0070.00713.21
7.3.210.0090.00313.18
7.3.200.0000.01213.18
7.3.190.0060.00613.13
7.3.180.0110.00213.44
7.3.170.0100.00313.17
7.3.160.0070.00513.14
7.3.150.0100.00213.31
7.3.140.0110.00213.30
7.3.130.0040.00813.21
7.3.120.0100.00213.14
7.3.110.0040.00913.31
7.3.100.0040.00813.13
7.3.90.0120.00013.61
7.3.80.0080.00413.38
7.3.70.0120.00013.27
7.3.60.0050.00513.42
7.3.50.0000.00813.18
7.3.40.0050.00213.42
7.3.30.0040.00413.26
7.3.20.0080.00015.10
7.3.10.0090.00014.91
7.3.00.0040.00414.86

preferences:
42.83 ms | 851 KiB | 5 Q