Intrvw: Difference between revisions

1,609 bytes added ,  2 years ago
Line 1:
= MSAmzn SysDE II =
 
* Coding
<pre>
## Write a function that gives you the average latency in a log file with the following format
#
# timestamp requestid operation latency
# 2021-01-20T08:19:18+00:00 123e4567-e89b-12d3-a456-426614174000 getresults 175
# 2021-01-20T08:19:20+00:00 123e4567-e89b-12d3-a456-426614174100 submitquery 100
# 2021-01-20T08:19:21+00:00 123e4567-e89b-12d3-a456-426614174200 getquerystatus 60
# 2021-01-20T08:20:03+00:00 123e4567-e89b-12d3-a456-426614174300 getresults 150
# 2021-01-20T08:22:09+00:00 123e4567-e89b-12d3-a456-426614174400 cancelquery 20
 
}
 
path = input('')
#path = '/var/log/messages'
 
r = []
 
with open(path,'r') as file:
for line in file:
r.append(line.split()[-1])
 
avg_Latency = sum(r)/len(r)
 
print(avg_Latency)
 
--------------------------------------
 
#path = input('')
 
 
def avg_lat(path):
#a = 0
#rr = 0
latency = {}
occurrence = {}
with open(path,'r') as file:
for line in file:
try:
c = line.split()[-1]
if int(c):
#a += 1
#rr = rr + int(c)
latency['getresults']
oper.update({line.split()[-2]:line.split()[-1]})
except:
pass
latency = {
'getresults': 455,
'submitquery': 678
...
}
occurrences = {
'getresults': 4,
'submitquery': 9
}
latency.get('getresults')
#return (rr/a)
 
 
avg_lat('/var/log/syslog')
</pre>
 
= MasterCard =
 
* SSL Handshake
* TCP 3-Way Handshake
 
 
= Microsoft =
 
;HM Round: