? ? Pending

User tests: Successful: Unsuccessful:

avatar csthomas
csthomas
1 Sep 2016

Summary of Changes

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

Testing Instructions

Code review, Travis and Jenkins tests only.

avatar csthomas csthomas - open - 1 Sep 2016
avatar csthomas csthomas - change - 1 Sep 2016
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 1 Sep 2016
Category Unit Tests
avatar joomla-cms-bot joomla-cms-bot - change - 1 Sep 2016
Labels Added: ? ?
avatar csthomas csthomas - change - 1 Sep 2016
Title
Reduce cache tests sleep(5) to sleep(3)
Reduce waiting time (sleep) in the cache tests
avatar csthomas
csthomas - comment - 1 Sep 2016

I did it in another way #11872.
testGc currently test almost nothing:)

avatar andrepereiradasilva
andrepereiradasilva - comment - 1 Sep 2016
# 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?

avatar mbabker
mbabker - comment - 1 Sep 2016

Did you run composer install? Should have the bin file at libraries/vendor/bin/phpunit which symlinks to libraries/vendor/phpunit/phpunit/phpunit.

avatar andrepereiradasilva
andrepereiradasilva - comment - 1 Sep 2016

ups

avatar andrepereiradasilva
andrepereiradasilva - comment - 1 Sep 2016

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.

avatar csthomas
csthomas - comment - 1 Sep 2016

Is there any min limit for lifetime? 1 or 2? or something between? Can we use 1.x?

avatar andrepereiradasilva
andrepereiradasilva - comment - 1 Sep 2016

it seems so ... @mbabker ?

avatar csthomas
csthomas - comment - 1 Sep 2016

filesystem min interval is probably 1 second.

avatar mbabker
mbabker - comment - 1 Sep 2016

I don't think there is a minimum.

avatar andrepereiradasilva
andrepereiradasilva - comment - 1 Sep 2016

with 1.2 as lifetime
Time: 8.67 seconds, Memory: 10.00MB

avatar andrepereiradasilva
andrepereiradasilva - comment - 1 Sep 2016

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.

avatar csthomas
csthomas - comment - 1 Sep 2016

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.

avatar andrepereiradasilva
andrepereiradasilva - comment - 1 Sep 2016

it seems i have also CacheLite so my tests are for file + cachelite

avatar mbabker
mbabker - comment - 1 Sep 2016

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.

avatar csthomas
csthomas - comment - 1 Sep 2016

IMHO we should also check testCacheTimeout whether at least first call of get return valid data and after lifetime return false.

avatar andrepereiradasilva
andrepereiradasilva - comment - 1 Sep 2016

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.

avatar csthomas
csthomas - comment - 1 Sep 2016

Thanks. I will check that but today is too late for me.

avatar andrepereiradasilva
andrepereiradasilva - comment - 1 Sep 2016

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.

avatar csthomas
csthomas - comment - 1 Sep 2016

I will test it and merge but for memcache there probably will be 1 second as minimum.

avatar andrepereiradasilva
andrepereiradasilva - comment - 1 Sep 2016

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!

avatar csthomas
csthomas - comment - 1 Sep 2016

I thought about lifetime=0.1, we can not put it in memcache(-d) param lifetime which should be int.

avatar andrepereiradasilva
andrepereiradasilva - comment - 2 Sep 2016

ok very nice improvement!

Tests made with File and Cache_Lite cache systems

Before

# php libraries/vendor/phpunit/phpunit/phpunit tests/unit/suites/libraries/joomla/cache
[...]
Time: 15.25 seconds, Memory: 10.00MB

After

# 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)

avatar andrepereiradasilva andrepereiradasilva - test_item - 2 Sep 2016 - Tested successfully
avatar andrepereiradasilva
andrepereiradasilva - comment - 2 Sep 2016

I have tested this item successfully on 4ffc8a1

as comments above


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11875.

avatar andrepereiradasilva
andrepereiradasilva - comment - 2 Sep 2016

@yvesh can you test this one so we get all unit tests pretty faster?

avatar csthomas
csthomas - comment - 2 Sep 2016

Please also take a look at #11872.

avatar wilsonge wilsonge - change - 3 Sep 2016
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2016-09-03 10:51:11
Closed_By wilsonge

Add a Comment

Login with GitHub to post a comment