Skip to content

code changes and results #69

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: feature/net-http-persistent-parallel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 22 additions & 18 deletions Samples/Authentication/src/StandAloneJWT.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,29 +146,33 @@ def do_one_payment

jwt_client = StandAloneJWT.new # ONE shared client

3.times do |iteration|
threads = []

5.times do |thread_idx|
threads << Thread.new do
CALLS_PER_THREAD.times do |call_idx|
status, latency = jwt_client.do_one_payment
lat_str = latency.negative? ? 'ERR' : format('%.1f', latency)

puts "Iteration #{iteration + 1}, T#{thread_idx + 1}-#{call_idx}: status=#{status} latency=#{lat_str} ms"
mutex.synchronize do
latencies << latency if latency.positive?
status_cnt[status] += 1
thread_nums = [10,20,30,40,50] # number of threads to test


thread_nums.each_with_index do |num_threads, iter_idx|
puts "\n--- Iteration #{iter_idx + 1} with #{num_threads} threads ---"
threads = []
num_threads.times do |thread_idx|
threads << Thread.new do
# puts "[Thread start] Iteration #{iter_idx + 1}, Thread index: #{thread_idx + 1}, Thread object_id: #{Thread.current.object_id}"
CALLS_PER_THREAD.times do |call_idx|
status, latency = jwt_client.do_one_payment
lat_str = latency.negative? ? 'ERR' : format('%.1f', latency)

puts "Iteration with #{num_threads} threads, T#{thread_idx + 1}-#{call_idx+1} [Thread #{Thread.current.object_id}]: status=#{status} latency=#{lat_str} ms , Thread object_id: #{Thread.current.object_id} "
mutex.synchronize do
latencies << latency if latency.positive?
status_cnt[status] += 1
end
end
end
end
threads.each(&:join)
sleep 10
puts " "
end

threads.each(&:join)
sleep 20
end

#####################################
#####################################
# SIMPLE STATISTICS
#####################################
unless latencies.empty?
Expand Down
163 changes: 163 additions & 0 deletions output.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
Iteration with 10 threads, T9-1: status=201 latency=1408.2 ms
Iteration with 10 threads, T7-1: status=201 latency=1455.7 ms
Iteration with 10 threads, T5-1: status=201 latency=1499.7 ms
Iteration with 10 threads, T10-1: status=201 latency=1480.1 ms
Iteration with 10 threads, T4-1: status=201 latency=1514.5 ms
Iteration with 10 threads, T1-1: status=201 latency=1568.9 ms
Iteration with 10 threads, T2-1: status=201 latency=1574.4 ms
Iteration with 10 threads, T3-1: status=201 latency=1665.8 ms
Iteration with 10 threads, T6-1: status=201 latency=1667.9 ms
Iteration with 10 threads, T8-1: status=201 latency=1898.2 ms

Iteration with 20 threads, T6-1: status=201 latency=771.2 ms
Iteration with 20 threads, T5-1: status=201 latency=779.1 ms
Iteration with 20 threads, T8-1: status=201 latency=774.3 ms
Iteration with 20 threads, T2-1: status=201 latency=789.6 ms
Iteration with 20 threads, T7-1: status=201 latency=792.3 ms
Iteration with 20 threads, T4-1: status=201 latency=873.4 ms
Iteration with 20 threads, T3-1: status=201 latency=875.9 ms
Iteration with 20 threads, T10-1: status=201 latency=867.1 ms
Iteration with 20 threads, T9-1: status=201 latency=949.6 ms
Iteration with 20 threads, T1-1: status=201 latency=1026.5 ms
Iteration with 20 threads, T17-1: status=201 latency=1342.1 ms
Iteration with 20 threads, T12-1: status=201 latency=1428.1 ms
Iteration with 20 threads, T11-1: status=201 latency=1458.5 ms
Iteration with 20 threads, T19-1: status=201 latency=1398.6 ms
Iteration with 20 threads, T14-1: status=201 latency=1465.3 ms
Iteration with 20 threads, T15-1: status=201 latency=1457.8 ms
Iteration with 20 threads, T16-1: status=201 latency=1575.7 ms
Iteration with 20 threads, T13-1: status=201 latency=1696.3 ms
Iteration with 20 threads, T18-1: status=201 latency=1686.5 ms
Iteration with 20 threads, T20-1: status=201 latency=1677.2 ms

Iteration with 30 threads, T1-1: status=201 latency=921.6 ms
Iteration with 30 threads, T6-1: status=201 latency=907.4 ms
Iteration with 30 threads, T9-1: status=201 latency=902.6 ms
Iteration with 30 threads, T12-1: status=201 latency=962.7 ms
Iteration with 30 threads, T4-1: status=201 latency=984.3 ms
Iteration with 30 threads, T11-1: status=201 latency=982.4 ms
Iteration with 30 threads, T18-1: status=201 latency=968.9 ms
Iteration with 30 threads, T2-1: status=201 latency=1018.4 ms
Iteration with 30 threads, T7-1: status=201 latency=1005.8 ms
Iteration with 30 threads, T20-1: status=201 latency=1147.8 ms
Iteration with 30 threads, T19-1: status=201 latency=1149.4 ms
Iteration with 30 threads, T16-1: status=201 latency=1153.6 ms
Iteration with 30 threads, T14-1: status=201 latency=1158.9 ms
Iteration with 30 threads, T13-1: status=201 latency=1160.8 ms
Iteration with 30 threads, T17-1: status=201 latency=1296.3 ms
Iteration with 30 threads, T10-1: status=201 latency=1311.0 ms
Iteration with 30 threads, T5-1: status=201 latency=1322.4 ms
Iteration with 30 threads, T15-1: status=201 latency=1300.3 ms
Iteration with 30 threads, T3-1: status=201 latency=1563.7 ms
Iteration with 30 threads, T8-1: status=201 latency=1552.2 ms
Iteration with 30 threads, T22-1: status=201 latency=1519.0 ms
Iteration with 30 threads, T28-1: status=201 latency=1489.3 ms
Iteration with 30 threads, T26-1: status=201 latency=1502.2 ms
Iteration with 30 threads, T24-1: status=201 latency=1618.0 ms
Iteration with 30 threads, T29-1: status=201 latency=1586.0 ms
Iteration with 30 threads, T25-1: status=201 latency=1611.5 ms
Iteration with 30 threads, T23-1: status=201 latency=1721.4 ms
Iteration with 30 threads, T27-1: status=201 latency=1693.4 ms
Iteration with 30 threads, T21-1: status=201 latency=1742.0 ms
Iteration with 30 threads, T30-1: status=201 latency=1771.1 ms

Iteration with 40 threads, T5-1: status=201 latency=1143.9 ms
Iteration with 40 threads, T9-1: status=201 latency=1137.1 ms
Iteration with 40 threads, T18-1: status=201 latency=1124.7 ms
Iteration with 40 threads, T24-1: status=201 latency=1117.5 ms
Iteration with 40 threads, T3-1: status=201 latency=1148.3 ms
Iteration with 40 threads, T10-1: status=201 latency=1136.3 ms
Iteration with 40 threads, T28-1: status=201 latency=1113.7 ms
Iteration with 40 threads, T1-1: status=201 latency=1153.1 ms
Iteration with 40 threads, T2-1: status=201 latency=1151.1 ms
Iteration with 40 threads, T23-1: status=201 latency=1120.4 ms
Iteration with 40 threads, T20-1: status=201 latency=1124.5 ms
Iteration with 40 threads, T13-1: status=201 latency=1133.8 ms
Iteration with 40 threads, T12-1: status=201 latency=1291.4 ms
Iteration with 40 threads, T7-1: status=201 latency=1300.0 ms
Iteration with 40 threads, T15-1: status=201 latency=1287.8 ms
Iteration with 40 threads, T17-1: status=201 latency=1285.2 ms
Iteration with 40 threads, T4-1: status=201 latency=1305.4 ms
Iteration with 40 threads, T19-1: status=201 latency=1283.1 ms
Iteration with 40 threads, T11-1: status=201 latency=1293.9 ms
Iteration with 40 threads, T29-1: status=201 latency=1271.8 ms
Iteration with 40 threads, T6-1: status=201 latency=1302.8 ms
Iteration with 40 threads, T22-1: status=201 latency=1399.2 ms
Iteration with 40 threads, T27-1: status=201 latency=1394.0 ms
Iteration with 40 threads, T25-1: status=201 latency=1400.4 ms
Iteration with 40 threads, T16-1: status=201 latency=1412.0 ms
Iteration with 40 threads, T30-1: status=201 latency=1395.9 ms
Iteration with 40 threads, T14-1: status=201 latency=1415.3 ms
Iteration with 40 threads, T21-1: status=201 latency=1460.2 ms
Iteration with 40 threads, T8-1: status=201 latency=1479.0 ms
Iteration with 40 threads, T26-1: status=201 latency=1512.0 ms
Iteration with 40 threads, T32-1: status=201 latency=1986.8 ms
Iteration with 40 threads, T39-1: status=201 latency=1938.7 ms
Iteration with 40 threads, T31-1: status=201 latency=1996.7 ms
Iteration with 40 threads, T35-1: status=201 latency=1963.6 ms
Iteration with 40 threads, T36-1: status=201 latency=1957.2 ms
Iteration with 40 threads, T38-1: status=201 latency=2226.6 ms
Iteration with 40 threads, T33-1: status=201 latency=2260.0 ms
Iteration with 40 threads, T37-1: status=201 latency=2233.7 ms
Iteration with 40 threads, T34-1: status=201 latency=2253.4 ms
Iteration with 40 threads, T40-1: status=201 latency=2216.6 ms

Iteration with 50 threads, T40-1: status=201 latency=1276.4 ms
Iteration with 50 threads, T25-1: status=201 latency=1302.7 ms
Iteration with 50 threads, T7-1: status=201 latency=1328.2 ms
Iteration with 50 threads, T8-1: status=201 latency=1327.3 ms
Iteration with 50 threads, T29-1: status=201 latency=1318.6 ms
Iteration with 50 threads, T18-1: status=201 latency=1351.1 ms
Iteration with 50 threads, T3-1: status=201 latency=1374.8 ms
Iteration with 50 threads, T4-1: status=201 latency=1373.3 ms
Iteration with 50 threads, T6-1: status=201 latency=1423.7 ms
Iteration with 50 threads, T15-1: status=201 latency=1410.5 ms
Iteration with 50 threads, T28-1: status=201 latency=1394.2 ms
Iteration with 50 threads, T1-1: status=201 latency=1435.7 ms
Iteration with 50 threads, T13-1: status=201 latency=1414.3 ms
Iteration with 50 threads, T26-1: status=201 latency=1397.7 ms
Iteration with 50 threads, T36-1: status=201 latency=1386.3 ms
Iteration with 50 threads, T31-1: status=201 latency=1392.9 ms
Iteration with 50 threads, T17-1: status=201 latency=1506.3 ms
Iteration with 50 threads, T19-1: status=201 latency=1503.9 ms
Iteration with 50 threads, T14-1: status=201 latency=1511.1 ms
Iteration with 50 threads, T2-1: status=201 latency=1531.5 ms
Iteration with 50 threads, T42-1: status=201 latency=1509.0 ms
Iteration with 50 threads, T9-1: status=201 latency=1630.7 ms
Iteration with 50 threads, T27-1: status=201 latency=1697.2 ms
Iteration with 50 threads, T33-1: status=201 latency=1690.5 ms
Iteration with 50 threads, T24-1: status=201 latency=1701.1 ms
Iteration with 50 threads, T21-1: status=201 latency=1704.7 ms
Iteration with 50 threads, T10-1: status=201 latency=1720.3 ms
Iteration with 50 threads, T11-1: status=201 latency=1718.8 ms
Iteration with 50 threads, T34-1: status=201 latency=1689.2 ms
Iteration with 50 threads, T23-1: status=201 latency=1702.6 ms
Iteration with 50 threads, T16-1: status=201 latency=1720.7 ms
Iteration with 50 threads, T20-1: status=201 latency=1715.3 ms
Iteration with 50 threads, T30-1: status=201 latency=1703.4 ms
Iteration with 50 threads, T32-1: status=201 latency=1701.4 ms
Iteration with 50 threads, T50-1: status=201 latency=1632.9 ms
Iteration with 50 threads, T38-1: status=201 latency=1694.2 ms
Iteration with 50 threads, T22-1: status=201 latency=1713.0 ms
Iteration with 50 threads, T12-1: status=201 latency=1726.6 ms
Iteration with 50 threads, T44-1: status=201 latency=1669.1 ms
Iteration with 50 threads, T39-1: status=201 latency=1749.7 ms
Iteration with 50 threads, T37-1: status=201 latency=1751.8 ms
Iteration with 50 threads, T49-1: status=201 latency=1716.0 ms
Iteration with 50 threads, T5-1: status=201 latency=1829.0 ms
Iteration with 50 threads, T46-1: status=201 latency=1875.2 ms
Iteration with 50 threads, T45-1: status=201 latency=1881.3 ms
Iteration with 50 threads, T41-1: status=201 latency=1910.5 ms
Iteration with 50 threads, T43-1: status=201 latency=1925.9 ms
Iteration with 50 threads, T48-1: status=201 latency=1925.7 ms
Iteration with 50 threads, T35-1: status=201 latency=1978.4 ms
Iteration with 50 threads, T47-1: status=201 latency=2036.9 ms


----- SUMMARY -----
Total calls : 150
Average latency : 1454.3 ms
Min / Max : 771.2 / 2260.0 ms

Status histogram:
201 : 150
Loading