##// END OF EJS Templates
Added mem_watch script. Test can also walk on file tree. Fixed some path issues
marcink -
r1334:08cd0237 beta
parent child Browse files
Show More
@@ -0,0 +1,1 b''
1 ps -eo size,pid,user,command --sort -size | awk '{ hr=$1/1024 ; printf("%13.2f Mb ",hr) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }'|grep paster
@@ -1,96 +1,130 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """
2 """
3 rhodecode.tests.test_crawer
3 rhodecode.tests.test_crawer
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
5
5
6 Test for crawling a project for memory usage
6 Test for crawling a project for memory usage
7
7
8 watch -n 1 "ps aux |grep paster"
8 watch -n1 ./rhodecode/tests/mem_watch
9
9
10 :created_on: Apr 21, 2010
10 :created_on: Apr 21, 2010
11 :author: marcink
11 :author: marcink
12 :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com>
12 :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com>
13 :license: GPLv3, see COPYING for more details.
13 :license: GPLv3, see COPYING for more details.
14 """
14 """
15 # This program is free software: you can redistribute it and/or modify
15 # This program is free software: you can redistribute it and/or modify
16 # it under the terms of the GNU General Public License as published by
16 # it under the terms of the GNU General Public License as published by
17 # the Free Software Foundation, either version 3 of the License, or
17 # the Free Software Foundation, either version 3 of the License, or
18 # (at your option) any later version.
18 # (at your option) any later version.
19 #
19 #
20 # This program is distributed in the hope that it will be useful,
20 # This program is distributed in the hope that it will be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 # GNU General Public License for more details.
23 # GNU General Public License for more details.
24 #
24 #
25 # You should have received a copy of the GNU General Public License
25 # You should have received a copy of the GNU General Public License
26 # along with this program. If not, see <http://www.gnu.org/licenses/>.
26 # along with this program. If not, see <http://www.gnu.org/licenses/>.
27
27
28
28
29 import cookielib
29 import cookielib
30 import urllib
30 import urllib
31 import urllib2
31 import urllib2
32 import vcs
32 import vcs
33 import time
33 import time
34
34
35 from os.path import join as jn
36
37
35 BASE_URI = 'http://127.0.0.1:5000/%s'
38 BASE_URI = 'http://127.0.0.1:5000/%s'
36 PROJECT = 'rhodecode'
39 PROJECT = 'CPython'
40 PROJECT_PATH = jn('/', 'home', 'marcink', 'hg_repos')
37
41
38
42
39 cj = cookielib.FileCookieJar('/tmp/rc_test_cookie.txt')
43 cj = cookielib.FileCookieJar('/tmp/rc_test_cookie.txt')
40 o = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
44 o = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
41 o.addheaders = [
45 o.addheaders = [
42 ('User-agent', 'rhodecode-crawler'),
46 ('User-agent', 'rhodecode-crawler'),
43 ('Accept-Language', 'en - us, en;q = 0.5')
47 ('Accept-Language', 'en - us, en;q = 0.5')
44 ]
48 ]
45
49
46 urllib2.install_opener(o)
50 urllib2.install_opener(o)
47
51
48
52
49
53
50 def test_changelog_walk(pages=100):
54 def test_changelog_walk(pages=100):
51 total_time = 0
55 total_time = 0
52 for i in range(1, pages):
56 for i in range(1, pages):
53
57
54 page = '/'.join((PROJECT, 'changelog',))
58 page = '/'.join((PROJECT, 'changelog',))
55
59
56 full_uri = (BASE_URI % page) + '?' + urllib.urlencode({'page':i})
60 full_uri = (BASE_URI % page) + '?' + urllib.urlencode({'page':i})
57 s = time.time()
61 s = time.time()
58 f = o.open(full_uri)
62 f = o.open(full_uri)
59 size = len(f.read())
63 size = len(f.read())
60 e = time.time() - s
64 e = time.time() - s
61 total_time += e
65 total_time += e
62 print 'visited %s size:%s req:%s ms' % (full_uri, size, e)
66 print 'visited %s size:%s req:%s ms' % (full_uri, size, e)
63
67
64
68
65 print 'total_time', total_time
69 print 'total_time', total_time
66 print 'average on req', total_time / float(pages)
70 print 'average on req', total_time / float(pages)
67
71
68
72
69 def test_changeset_walk():
73 def test_changeset_walk():
74 print jn(PROJECT_PATH, PROJECT)
75 total_time = 0
70
76
71 # test against self
77 repo = vcs.get_repo(jn(PROJECT_PATH, PROJECT))
72 repo = vcs.get_repo('../../../rhodecode')
73
78
74 total_time = 0
75 for i in repo:
79 for i in repo:
76
80
77 raw_cs = '/'.join((PROJECT, 'changeset', i.raw_id))
81 raw_cs = '/'.join((PROJECT, 'changeset', i.raw_id))
78
82
79 full_uri = (BASE_URI % raw_cs)
83 full_uri = (BASE_URI % raw_cs)
80 s = time.time()
84 s = time.time()
81 f = o.open(full_uri)
85 f = o.open(full_uri)
82 size = len(f.read())
86 size = len(f.read())
83 e = time.time() - s
87 e = time.time() - s
84 total_time += e
88 total_time += e
85 print 'visited %s\%s size:%s req:%s ms' % (full_uri, i, size, e)
89 print 'visited %s\%s size:%s req:%s ms' % (full_uri, i, size, e)
86
90
87 print 'total_time', total_time
91 print 'total_time', total_time
88 print 'average on req', total_time / float(len(repo))
92 print 'average on req', total_time / float(len(repo))
89
93
90 def test_files_walk():
94 def test_files_walk():
91 pass
95 print jn(PROJECT_PATH, PROJECT)
96 total_time = 0
97
98 repo = vcs.get_repo(jn(PROJECT_PATH, PROJECT))
99
100 paths_ = set()
101 try:
102 tip = repo.get_changeset('tip')
103 for topnode, dirs, files in tip.walk('/'):
104 for f in files:
105 paths_.add(f.path)
106 for dir in dirs:
107 for f in files:
108 paths_.add(f.path)
109
110 except vcs.exception.RepositoryError, e:
111 pass
112
113 for f in paths_:
114 file_path = '/'.join((PROJECT, 'files', 'tip', f))
115
116 full_uri = (BASE_URI % file_path)
117 s = time.time()
118 f = o.open(full_uri)
119 size = len(f.read())
120 e = time.time() - s
121 total_time += e
122 print 'visited %s size:%s req:%s ms' % (full_uri, size, e)
123
124 print 'total_time', total_time
125 print 'average on req', total_time / float(len(repo))
92
126
93
127
94
128 #test_changelog_walk()
95 test_changelog_walk()
96 #test_changeset_walk()
129 #test_changeset_walk()
130 test_files_walk()
General Comments 0
You need to be logged in to leave comments. Login now