Пешком на Камчатку...
испытания такие: $ab -n 2000 -c 20 bugs.adsorbtion.org/
Лишнее опускаю.
qw = self.hlp.include("sql", "count", 0, tbl = tbl, where = clause) Cаму функцию уже приводил
Finished 2000 requests
Document Path: /
Document Length: 323 bytes
Concurrency Level: 20
Time taken for tests: 0.687 seconds
Complete requests: 2000
Failed requests: 5
(Connect: 0, Receive: 0, Length: 5, Exceptions: 0)
Write errors: 0
Non-2xx responses: 2003
Total transferred: 1137992 bytes
HTML transferred: 654339 bytes
Requests per second: 2909.90 [#/sec] (mean)
Time per request: 6.873 [ms] (mean)
Time per request: 0.344 [ms] (mean, across all concurrent requests)
Transfer rate: 1616.92 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1 0.9 1 12
Processing: 2 5 22.1 3 461
Waiting: 1 5 21.8 2 460
Total: 2 7 22.1 4 462
Percentage of the requests served within a certain time (ms)
50% 4
66% 5
75% 6
80% 7
90% 10
95% 11
98% 13
99% 14
100% 462 (longest request)
qw = 'SELECT COUNT(*) FROM `'+tbl+'` '+clause
Time taken for tests: 0.840 seconds
Complete requests: 2000
Failed requests: 5
(Connect: 0, Receive: 0, Length: 5, Exceptions: 0)
Write errors: 0
Non-2xx responses: 2003
Total transferred: 1137992 bytes
HTML transferred: 654339 bytes
Requests per second: 2382.17 [#/sec] (mean)
Time per request: 8.396 [ms] (mean)
Time per request: 0.420 [ms] (mean, across all concurrent requests)
Transfer rate: 1323.67 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 2 2.1 1 20
Processing: 1 6 27.0 3 595
Waiting: 1 5 26.7 3 587
Total: 2 8 27.0 5 595
Percentage of the requests served within a certain time (ms)
50% 5
66% 6
75% 8
80% 9
90% 13
95% 16
98% 19
99% 20
100% 595 (longest request)
Этим я доказал себе, что старый метот с инклудом и регулярками выгоднее.
Теперь так:
qw = ''.join(['SELECT COUNT(*) FROM `', tbl, '` ', clause])
Time taken for tests: 0.797 seconds
Complete requests: 2000
Failed requests: 4
(Connect: 0, Receive: 0, Length: 4, Exceptions: 0)
Write errors: 0
Non-2xx responses: 2001
Total transferred: 1135204 bytes
HTML transferred: 652219 bytes
Requests per second: 2509.06 [#/sec] (mean)
Time per request: 7.971 [ms] (mean)
Time per request: 0.399 [ms] (mean, across all concurrent requests)
Transfer rate: 1390.77 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1 1.3 1 13
Processing: 2 6 20.7 4 545
Waiting: 0 5 20.4 3 538
Total: 4 8 20.8 5 548
Percentage of the requests served within a certain time (ms)
50% 5
66% 6
75% 8
80% 9
90% 11
95% 14
98% 16
99% 17
100% 548 (longest request)
Опять же меня успокаивает. Если кто возмутится, что я использую функцию с регулярками, то покажу ему тесты. В принципе, когда используется регулярка, то большая часть строки уже в памяти, и нужно заменить ерунду, в остальных случаях создаются новые блоки со строкой. В данном тесте функция с примером вызывается один раз, если вызывать миллион, то, думаю, прирост производительности будет безумно заметен.
Да, еще тест показывает, что что джойнить строки выгоднее, чем собирать плюсами.
Лишнее опускаю.
qw = self.hlp.include("sql", "count", 0, tbl = tbl, where = clause) Cаму функцию уже приводил
Finished 2000 requests
Document Path: /
Document Length: 323 bytes
Concurrency Level: 20
Time taken for tests: 0.687 seconds
Complete requests: 2000
Failed requests: 5
(Connect: 0, Receive: 0, Length: 5, Exceptions: 0)
Write errors: 0
Non-2xx responses: 2003
Total transferred: 1137992 bytes
HTML transferred: 654339 bytes
Requests per second: 2909.90 [#/sec] (mean)
Time per request: 6.873 [ms] (mean)
Time per request: 0.344 [ms] (mean, across all concurrent requests)
Transfer rate: 1616.92 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1 0.9 1 12
Processing: 2 5 22.1 3 461
Waiting: 1 5 21.8 2 460
Total: 2 7 22.1 4 462
Percentage of the requests served within a certain time (ms)
50% 4
66% 5
75% 6
80% 7
90% 10
95% 11
98% 13
99% 14
100% 462 (longest request)
qw = 'SELECT COUNT(*) FROM `'+tbl+'` '+clause
Time taken for tests: 0.840 seconds
Complete requests: 2000
Failed requests: 5
(Connect: 0, Receive: 0, Length: 5, Exceptions: 0)
Write errors: 0
Non-2xx responses: 2003
Total transferred: 1137992 bytes
HTML transferred: 654339 bytes
Requests per second: 2382.17 [#/sec] (mean)
Time per request: 8.396 [ms] (mean)
Time per request: 0.420 [ms] (mean, across all concurrent requests)
Transfer rate: 1323.67 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 2 2.1 1 20
Processing: 1 6 27.0 3 595
Waiting: 1 5 26.7 3 587
Total: 2 8 27.0 5 595
Percentage of the requests served within a certain time (ms)
50% 5
66% 6
75% 8
80% 9
90% 13
95% 16
98% 19
99% 20
100% 595 (longest request)
Этим я доказал себе, что старый метот с инклудом и регулярками выгоднее.
Теперь так:
qw = ''.join(['SELECT COUNT(*) FROM `', tbl, '` ', clause])
Time taken for tests: 0.797 seconds
Complete requests: 2000
Failed requests: 4
(Connect: 0, Receive: 0, Length: 4, Exceptions: 0)
Write errors: 0
Non-2xx responses: 2001
Total transferred: 1135204 bytes
HTML transferred: 652219 bytes
Requests per second: 2509.06 [#/sec] (mean)
Time per request: 7.971 [ms] (mean)
Time per request: 0.399 [ms] (mean, across all concurrent requests)
Transfer rate: 1390.77 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1 1.3 1 13
Processing: 2 6 20.7 4 545
Waiting: 0 5 20.4 3 538
Total: 4 8 20.8 5 548
Percentage of the requests served within a certain time (ms)
50% 5
66% 6
75% 8
80% 9
90% 11
95% 14
98% 16
99% 17
100% 548 (longest request)
Опять же меня успокаивает. Если кто возмутится, что я использую функцию с регулярками, то покажу ему тесты. В принципе, когда используется регулярка, то большая часть строки уже в памяти, и нужно заменить ерунду, в остальных случаях создаются новые блоки со строкой. В данном тесте функция с примером вызывается один раз, если вызывать миллион, то, думаю, прирост производительности будет безумно заметен.
Да, еще тест показывает, что что джойнить строки выгоднее, чем собирать плюсами.