Advertisement
rex9840

Response_time_evaluator_

May 11th, 2021
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.69 KB | None | 0 0
  1. import requests
  2. import csv
  3. import pandas as pd
  4.  
  5.  
  6.  
  7. data=dict()
  8. date=list()
  9. time=list()
  10. request=list()
  11. timetaken=list()
  12. path=list()
  13.  
  14.  
  15. def web_request() -> str:
  16.     file = requests.get("http://ka-mao.xyz/log/rtime")
  17.     return file.text
  18.  
  19.  
  20. def dataframe_dict() -> None :
  21.     lines=web_request().split("\n")
  22.     for line in lines[:-1]:
  23.  
  24.             sep=line.split(' ')
  25.            
  26.             # print(sep[0])
  27.             # print(sep[1])
  28.             # print(sep[4])
  29.             # print(sep[5])
  30.             # print(sep[-2])
  31.            
  32.  
  33.             date.append(sep[0].replace(',',''))
  34.             time.append(sep[1])
  35.             request.append(sep[4])
  36.             path.append(sep[5])
  37.            
  38.            
  39.             timetaken.append(float(line.split(' ')[-2].replace('ms',"")))
  40.        
  41.        
  42. dataframe_dict()
  43.  
  44.  
  45.  
  46. def dataframe()    -> None :        
  47.     data={'date':date,"time":time ,'request ':request ,"path ":path ,"timetaken":timetaken}
  48.     print('size of the columns :',end='\n')
  49.     print('date:',len(date),'time:',len(time),'request:',len(request),'path:',len(path),'timetaken:',len(timetaken))
  50.     df = pd.DataFrame.from_dict(data=data,orient='columns')
  51.     # df=df.transpose()
  52.  
  53.     df.to_csv('./timeout.csv')      
  54.  
  55.     max:int
  56.     min:int
  57.     for x in range(len(df['timetaken'])):
  58.         if df['timetaken'].max()==df['timetaken'][x]:
  59.             max=x
  60.            
  61.         if df['timetaken'].min()==df['timetaken'][x]:
  62.             min =x
  63.            
  64.     print ('--'*50)
  65.     print('MAX:')
  66.     print()
  67.     print(df.iloc[max])
  68.     print("--"*50)
  69.     print('MIN:')
  70.     print()
  71.     print(df.iloc[min])        
  72.            
  73.    
  74. dataframe()    
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement