On Saturday 22 Aug 2015 20:03 CEST, Cecil Westerhof wrote:

> On Saturday 22 Aug 2015 17:33 CEST, Michael Torrie wrote:
>
>> On 08/22/2015 05:37 AM, Cecil Westerhof wrote:
>>>> I don't know. Is it bottle, or the browser, or something
>>>> completely different that eats the extra time?
>>>
>>> I really do not know. I suspect bottle, but I am new to this, so I
>>> value the suspicion of someone who has more experience more. :-D
>>
>> These are requests performed from browser Javascript (ajax), right?
>> Could you write a shell script that fetches these urls in sequence
>> using curl or wget, simulating the web browser? This would let you
>> check times in a controlled way, without the variable of the
>> browser itself.
>
> I should have thought about that myself. :-(

I used Python instead of a shell script of-course. :-P

========================================================================
#!/usr/bin/env python3

import time

from urllib.request import urlopen


server = 'http://localhost:8080'
urls   = [
    '/',
    '/static/css/default.css',
    '/static/JavaScript/angular.js',
    '/static/appPublishedPhotos.js',
    '/links/data',
    '/versionPython',
    '/versionSQLite',
]
for x in range(0, 10):
    start_time = time.time()
    for url in urls:
        print(url)
        urlopen(server + url).read()
    end_time = time.time()
    print('It took {0} seconds\n'.format(end_time - start_time), flush = True)
    time.sleep(20)
========================================================================

It is not perfect code, no error checking and the last sleep is
superfluous, but for the current job good enough.

I have included the output as attachment. It is clear that bottle is
not the problem: fetching all the data takes at most 0.017 seconds.

/
/static/css/default.css
/static/JavaScript/angular.js
/static/appPublishedPhotos.js
/links/data
/versionPython
/versionSQLite
It took 0.012779951095581055 seconds

/
/static/css/default.css
/static/JavaScript/angular.js
/static/appPublishedPhotos.js
/links/data
/versionPython
/versionSQLite
It took 0.010144948959350586 seconds

/
/static/css/default.css
/static/JavaScript/angular.js
/static/appPublishedPhotos.js
/links/data
/versionPython
/versionSQLite
It took 0.010040283203125 seconds

/
/static/css/default.css
/static/JavaScript/angular.js
/static/appPublishedPhotos.js
/links/data
/versionPython
/versionSQLite
It took 0.013696908950805664 seconds

/
/static/css/default.css
/static/JavaScript/angular.js
/static/appPublishedPhotos.js
/links/data
/versionPython
/versionSQLite
It took 0.01705002784729004 seconds

/
/static/css/default.css
/static/JavaScript/angular.js
/static/appPublishedPhotos.js
/links/data
/versionPython
/versionSQLite
It took 0.009366750717163086 seconds

/
/static/css/default.css
/static/JavaScript/angular.js
/static/appPublishedPhotos.js
/links/data
/versionPython
/versionSQLite
It took 0.011032581329345703 seconds

/
/static/css/default.css
/static/JavaScript/angular.js
/static/appPublishedPhotos.js
/links/data
/versionPython
/versionSQLite
It took 0.015336990356445312 seconds

/
/static/css/default.css
/static/JavaScript/angular.js
/static/appPublishedPhotos.js
/links/data
/versionPython
/versionSQLite
It took 0.016999244689941406 seconds

/
/static/css/default.css
/static/JavaScript/angular.js
/static/appPublishedPhotos.js
/links/data
/versionPython
/versionSQLite
It took 0.010639429092407227 seconds

So my next bet is AngularJS.

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to