User tests: Successful: Unsuccessful:
Reduce time of tests for travis and etc.
For my laptop (file, apcu, memcache, memcached):
php libraries/vendor/phpunit/phpunit/phpunit tests/unit/suites/libraries/joomla/cache
Before patch:
Time: 23.24 seconds, Memory: 10.00MB
After patch:
Time: 15.26 seconds, Memory: 10.00MB
Code review, Travis and Jenkins tests only.
Status | New | ⇒ | Pending |
Category | ⇒ | Unit Tests |
Labels |
Added:
?
?
|
Title |
|
# php libraries/vendor/phpunit/phpunit/phpunit tests/unit/suites/libraries/joomla/cache
Could not open input file: libraries/vendor/phpunit/phpunit/phpunit
Need to install something to make the tests?
Did you run composer install
? Should have the bin file at libraries/vendor/bin/phpunit
which symlinks to libraries/vendor/phpunit/phpunit/phpunit
.
ups
with (only changed in changed in JCacheTest.php and in JCacheStorageFileTest.php)
$this->handler->_lifetime = 1.5;
[...]
usleep(1.5 * 1000000 + 500000);
i got from
Time: 15.27 seconds, Memory: 10.00MB
to
Time: 9.26 seconds, Memory: 10.00MB
I only use file cache in my server.
Is there any min limit for lifetime? 1 or 2? or something between? Can we use 1.x?
filesystem min interval is probably 1 second.
I don't think there is a minimum.
with 1.2 as lifetime
Time: 8.67 seconds, Memory: 10.00MB
it fails in my server with 1.1, but them again this is file cache so should be slower
interresting you can set the lifetime as 0.1
just the check must be slower in file cache o is not elimited yet and the test fails.
For file handler we don't need to use usleep because filemtime does not depend on lifetime, for comparison with current time we use $handler->_now
IMHO Simple $this->handler->_now += $this->handler->_lifetime + 1;
should be enough.
it seems i have also CacheLite so my tests are for file + cachelite
If you run composer install
we have pear/cache_lite
as a dev dependency to be able to test our cache integration with it. There's your hidden bonus for the day.
IMHO we should also check testCacheTimeout
whether at least first call of get
return valid data and after lifetime return false.
see csthomas#2 0.4 sec for both "cache lite" and "file" test
i guess the same could be done for most of all other cache system tests, but i can't test.
Thanks. I will check that but today is too late for me.
ok, but just so you know, with those two changes in the cache systems i have (file and cache lite) my system went from:
Time: 15.27 seconds, Memory: 10.00MB
to
Time: 6.58 seconds, Memory: 10.00MB
So applying the same principle to all cache systems (and where sleep exists) would probably drasticly reduce the unit tests time.
I will test it and merge but for memcache there probably will be 1 second as minimum.
I will test it and merge but for memcache there probably will be 1 second as minimum.
Doesn't really matter how much time the cache system will take, just put inside the cycle and when cache is cleared it will exit the cycle and it's done! If not there's a 3 sec timeout and them fail!
I thought about lifetime=0.1, we can not put it in memcache(-d) param lifetime which should be int.
ok very nice improvement!
Tests made with File
and Cache_Lite
cache systems
# php libraries/vendor/phpunit/phpunit/phpunit tests/unit/suites/libraries/joomla/cache
[...]
Time: 15.25 seconds, Memory: 10.00MB
# php libraries/vendor/phpunit/phpunit/phpunit tests/unit/suites/libraries/joomla/cache
[...]
Time: 5.69 seconds, Memory: 10.00MB
(and this remaining 5 seconds are because of #11872, with that patch + my PR also applied it goes to 1 sec)
I have tested this item
as comments above
Status | Pending | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-09-03 10:51:11 |
Closed_By | ⇒ | wilsonge |
BTW you have other cache sleep here https://github.com/joomla/joomla-cms/blob/staging/tests/unit/suites/libraries/joomla/cache/JCacheTest.php#L450