-
-
Save namnh68/6a00bc24bae6deb7796a3ca92a9cbfdf to your computer and use it in GitHub Desktop.
Revisions
-
tovin07 renamed this gist
Apr 19, 2018 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
tovin07 revised this gist
Apr 19, 2018 . 2 changed files with 65 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,63 @@ (ping-Qi9wEmSd) ➜ ping python ping.py ---> 0.000 s: Ping host #000 ---> 0.000 s: Ping host #001 ---> 0.000 s: Ping host #002 <--- 0.369 s: Pinged host #000 in 0.363 s <--- 0.625 s: Pinged host #002 in 0.624 s <--- 0.826 s: Pinged host #001 in 0.822 s ---> 2.006 s: Ping host #001 <--- 2.917 s: Pinged host #001 in 0.906 s ---> 3.004 s: Ping host #000 <--- 3.446 s: Pinged host #000 in 0.439 s ---> 4.011 s: Ping host #001 <--- 4.061 s: Pinged host #001 in 0.044 s ---> 5.006 s: Ping host #002 <--- 5.869 s: Pinged host #002 in 0.861 s ---> 6.009 s: Ping host #000 ---> 6.012 s: Ping host #001 <--- 6.229 s: Pinged host #001 in 0.212 s <--- 6.444 s: Pinged host #000 in 0.429 s ---> 8.013 s: Ping host #001 <--- 8.850 s: Pinged host #001 in 0.831 s ---> 9.015 s: Ping host #000 <--- 9.907 s: Pinged host #000 in 0.890 s ---> 10.006 s: Ping host #002 ---> 10.014 s: Ping host #001 <--- 10.489 s: Pinged host #002 in 0.477 s <--- 10.889 s: Pinged host #001 in 0.869 s ---> 12.015 s: Ping host #001 ---> 12.016 s: Ping host #000 <--- 12.037 s: Pinged host #001 in 0.021 s <--- 12.209 s: Pinged host #000 in 0.190 s ---> 14.019 s: Ping host #001 <--- 14.521 s: Pinged host #001 in 0.497 s ---> 15.009 s: Ping host #002 ---> 15.017 s: Ping host #000 <--- 15.818 s: Pinged host #002 in 0.803 s <--- 15.842 s: Pinged host #000 in 0.824 s ---> 16.024 s: Ping host #001 <--- 16.370 s: Pinged host #001 in 0.345 s ---> 18.020 s: Ping host #000 ---> 18.025 s: Ping host #001 <--- 18.295 s: Pinged host #000 in 0.273 s <--- 18.842 s: Pinged host #001 in 0.812 s ---> 20.014 s: Ping host #002 ---> 20.026 s: Ping host #001 <--- 20.714 s: Pinged host #001 in 0.686 s <--- 20.818 s: Pinged host #002 in 0.799 s ---> 21.025 s: Ping host #000 <--- 21.425 s: Pinged host #000 in 0.397 s ---> 22.028 s: Ping host #001 <--- 22.893 s: Pinged host #001 in 0.865 s ---> 24.026 s: Ping host #000 ---> 24.028 s: Ping host #001 <--- 24.140 s: Pinged host #000 in 0.110 s <--- 24.627 s: Pinged host #001 in 0.598 s ---> 25.015 s: Ping host #002 <--- 25.636 s: Pinged host #002 in 0.620 s ---> 26.028 s: Ping host #001 <--- 26.814 s: Pinged host #001 in 0.782 s ---> 27.029 s: Ping host #000 <--- 27.771 s: Pinged host #000 in 0.737 s ---> 28.030 s: Ping host #001 <--- 28.467 s: Pinged host #001 in 0.431 s This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -29,7 +29,8 @@ '#016': 3, '#017': 8, '#018': 10, '#019': 9, '#020': 9 } HUGE_HOSTS = { -
tovin07 created this gist
Apr 19, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,47 @@ import asyncio import random import time import test_data start = time.time() async def ping(loop, host, interval): print("---> {:7.3f} s: Ping host {}".format(time.time() - start, host)) # After interval time, ping it again loop.call_later(interval, loop.create_task, ping(loop, host, interval)) # Generate random round trip time round_trip_time = random.random() # Fake wait with random round trip time await asyncio.sleep(round_trip_time) # Print done message print("<--- {:7.3f} s: Pinged host {} in {:.3f} s".format( time.time() - start, host, round_trip_time) ) def main(): # hosts = test_data.SINGLE_HOST hosts = test_data.TINY_HOSTS # hosts = test_data.SMALL_HOSTS # hosts = test_data.HUGE_HOSTS loop = asyncio.get_event_loop() for host, interval in hosts.items(): loop.call_soon(loop.create_task, ping(loop, host, interval)) # Stop after 30 seconds loop.call_later(30, loop.stop) # Make the loop run forever or stop after called loop.stop loop.run_forever() if __name__ == '__main__': main() This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,1037 @@ SINGLE_HOST = { '#000': 3, } TINY_HOSTS = { '#000': 3, '#001': 2, '#002': 5, } SMALL_HOSTS = { # 20 hosts '#000': 3, '#001': 2, '#002': 5, '#003': 1, '#004': 6, '#005': 3, '#006': 7, '#007': 2, '#008': 7, '#009': 5, '#010': 5, '#011': 10, '#012': 5, '#013': 2, '#014': 9, '#015': 5, '#016': 3, '#017': 8, '#018': 10, '#019': 9 } HUGE_HOSTS = { # 1000 hosts '#000': 3, '#001': 2, '#002': 5, '#003': 1, '#004': 6, '#005': 3, '#006': 7, '#007': 2, '#008': 7, '#009': 5, '#010': 5, '#011': 10, '#012': 5, '#013': 2, '#014': 9, '#015': 5, '#016': 3, '#017': 8, '#018': 10, '#019': 9, '#020': 9, '#021': 10, '#022': 3, '#023': 9, '#024': 2, '#025': 10, '#026': 6, '#027': 6, '#028': 3, '#029': 10, '#030': 2, '#031': 3, '#032': 2, '#033': 4, '#034': 8, '#035': 6, '#036': 8, '#037': 10, '#038': 9, '#039': 7, '#040': 6, '#041': 5, '#042': 2, '#043': 2, '#044': 7, '#045': 9, '#046': 7, '#047': 9, '#048': 9, '#049': 2, '#050': 2, '#051': 2, '#052': 10, '#053': 4, '#054': 5, '#055': 2, '#056': 10, '#057': 3, '#058': 3, '#059': 9, '#060': 2, '#061': 1, '#062': 3, '#063': 6, '#064': 2, '#065': 8, '#066': 4, '#067': 7, '#068': 10, '#069': 2, '#070': 2, '#071': 3, '#072': 4, '#073': 2, '#074': 1, '#075': 1, '#076': 5, '#077': 8, '#078': 8, '#079': 7, '#080': 2, '#081': 9, '#082': 3, '#083': 3, '#084': 4, '#085': 1, '#086': 3, '#087': 10, '#088': 2, '#089': 7, '#090': 7, '#091': 7, '#092': 3, '#093': 5, '#094': 5, '#095': 3, '#096': 4, '#097': 6, '#098': 1, '#099': 5, '#100': 7, '#101': 2, '#102': 5, '#103': 4, '#104': 1, '#105': 7, '#106': 6, '#107': 2, '#108': 6, '#109': 5, '#110': 5, '#111': 5, '#112': 6, '#113': 6, '#114': 1, '#115': 10, '#116': 7, '#117': 3, '#118': 1, '#119': 9, '#120': 7, '#121': 7, '#122': 2, '#123': 2, '#124': 10, '#125': 2, '#126': 5, '#127': 7, '#128': 7, '#129': 1, '#130': 3, '#131': 2, '#132': 4, '#133': 9, '#134': 2, '#135': 3, '#136': 6, '#137': 5, '#138': 7, '#139': 2, '#140': 5, '#141': 7, '#142': 8, '#143': 8, '#144': 4, '#145': 1, '#146': 3, '#147': 5, '#148': 9, '#149': 9, '#150': 5, '#151': 3, '#152': 4, '#153': 2, '#154': 6, '#155': 4, '#156': 9, '#157': 5, '#158': 1, '#159': 8, '#160': 1, '#161': 3, '#162': 10, '#163': 10, '#164': 1, '#165': 1, '#166': 2, '#167': 7, '#168': 6, '#169': 4, '#170': 10, '#171': 9, '#172': 1, '#173': 6, '#174': 4, '#175': 3, '#176': 1, '#177': 10, '#178': 6, '#179': 6, '#180': 4, '#181': 8, '#182': 3, '#183': 10, '#184': 4, '#185': 7, '#186': 1, '#187': 2, '#188': 10, '#189': 9, '#190': 6, '#191': 6, '#192': 1, '#193': 5, '#194': 3, '#195': 1, '#196': 8, '#197': 9, '#198': 5, '#199': 10, '#200': 6, '#201': 10, '#202': 2, '#203': 3, '#204': 1, '#205': 7, '#206': 3, '#207': 3, '#208': 8, '#209': 5, '#210': 3, '#211': 7, '#212': 10, '#213': 7, '#214': 6, '#215': 6, '#216': 6, '#217': 5, '#218': 1, '#219': 5, '#220': 6, '#221': 4, '#222': 4, '#223': 4, '#224': 7, '#225': 1, '#226': 2, '#227': 2, '#228': 3, '#229': 6, '#230': 7, '#231': 7, '#232': 2, '#233': 2, '#234': 9, '#235': 1, '#236': 8, '#237': 3, '#238': 5, '#239': 9, '#240': 2, '#241': 7, '#242': 1, '#243': 10, '#244': 3, '#245': 4, '#246': 1, '#247': 1, '#248': 7, '#249': 4, '#250': 5, '#251': 6, '#252': 4, '#253': 7, '#254': 8, '#255': 5, '#256': 9, '#257': 3, '#258': 1, '#259': 10, '#260': 10, '#261': 7, '#262': 2, '#263': 1, '#264': 1, '#265': 4, '#266': 2, '#267': 1, '#268': 7, '#269': 7, '#270': 4, '#271': 8, '#272': 9, '#273': 7, '#274': 1, '#275': 6, '#276': 2, '#277': 8, '#278': 8, '#279': 2, '#280': 3, '#281': 5, '#282': 10, '#283': 6, '#284': 2, '#285': 8, '#286': 6, '#287': 1, '#288': 7, '#289': 6, '#290': 4, '#291': 8, '#292': 10, '#293': 7, '#294': 7, '#295': 10, '#296': 5, '#297': 5, '#298': 5, '#299': 9, '#300': 8, '#301': 2, '#302': 4, '#303': 2, '#304': 1, '#305': 9, '#306': 5, '#307': 4, '#308': 4, '#309': 6, '#310': 9, '#311': 7, '#312': 4, '#313': 1, '#314': 1, '#315': 6, '#316': 3, '#317': 5, '#318': 9, '#319': 4, '#320': 9, '#321': 10, '#322': 4, '#323': 4, '#324': 1, '#325': 8, '#326': 7, '#327': 7, '#328': 7, '#329': 10, '#330': 10, '#331': 3, '#332': 6, '#333': 5, '#334': 9, '#335': 9, '#336': 7, '#337': 5, '#338': 3, '#339': 10, '#340': 8, '#341': 2, '#342': 1, '#343': 4, '#344': 8, '#345': 2, '#346': 8, '#347': 10, '#348': 4, '#349': 7, '#350': 2, '#351': 9, '#352': 10, '#353': 7, '#354': 1, '#355': 9, '#356': 4, '#357': 3, '#358': 9, '#359': 6, '#360': 3, '#361': 4, '#362': 5, '#363': 2, '#364': 4, '#365': 2, '#366': 9, '#367': 8, '#368': 5, '#369': 9, '#370': 10, '#371': 5, '#372': 8, '#373': 8, '#374': 5, '#375': 1, '#376': 5, '#377': 2, '#378': 4, '#379': 4, '#380': 9, '#381': 9, '#382': 3, '#383': 1, '#384': 7, '#385': 7, '#386': 6, '#387': 6, '#388': 5, '#389': 3, '#390': 7, '#391': 7, '#392': 7, '#393': 4, '#394': 3, '#395': 9, '#396': 2, '#397': 1, '#398': 7, '#399': 7, '#400': 4, '#401': 10, '#402': 8, '#403': 3, '#404': 6, '#405': 7, '#406': 7, '#407': 5, '#408': 6, '#409': 9, '#410': 10, '#411': 4, '#412': 6, '#413': 3, '#414': 10, '#415': 3, '#416': 10, '#417': 2, '#418': 2, '#419': 2, '#420': 1, '#421': 1, '#422': 2, '#423': 9, '#424': 9, '#425': 2, '#426': 7, '#427': 1, '#428': 9, '#429': 7, '#430': 6, '#431': 2, '#432': 3, '#433': 5, '#434': 2, '#435': 4, '#436': 2, '#437': 4, '#438': 2, '#439': 6, '#440': 2, '#441': 2, '#442': 7, '#443': 6, '#444': 8, '#445': 2, '#446': 10, '#447': 9, '#448': 3, '#449': 6, '#450': 1, '#451': 3, '#452': 9, '#453': 3, '#454': 1, '#455': 9, '#456': 8, '#457': 9, '#458': 10, '#459': 6, '#460': 4, '#461': 9, '#462': 7, '#463': 5, '#464': 7, '#465': 5, '#466': 1, '#467': 4, '#468': 4, '#469': 5, '#470': 9, '#471': 9, '#472': 9, '#473': 7, '#474': 6, '#475': 10, '#476': 4, '#477': 3, '#478': 3, '#479': 1, '#480': 9, '#481': 5, '#482': 7, '#483': 2, '#484': 8, '#485': 8, '#486': 5, '#487': 8, '#488': 5, '#489': 6, '#490': 9, '#491': 5, '#492': 5, '#493': 4, '#494': 8, '#495': 5, '#496': 8, '#497': 1, '#498': 6, '#499': 10, '#500': 2, '#501': 8, '#502': 2, '#503': 10, '#504': 9, '#505': 6, '#506': 5, '#507': 4, '#508': 8, '#509': 10, '#510': 4, '#511': 8, '#512': 9, '#513': 10, '#514': 1, '#515': 3, '#516': 6, '#517': 3, '#518': 6, '#519': 4, '#520': 5, '#521': 1, '#522': 2, '#523': 9, '#524': 10, '#525': 8, '#526': 7, '#527': 1, '#528': 3, '#529': 7, '#530': 9, '#531': 7, '#532': 10, '#533': 1, '#534': 9, '#535': 8, '#536': 5, '#537': 9, '#538': 9, '#539': 10, '#540': 1, '#541': 2, '#542': 1, '#543': 6, '#544': 5, '#545': 9, '#546': 3, '#547': 1, '#548': 3, '#549': 3, '#550': 9, '#551': 7, '#552': 2, '#553': 10, '#554': 3, '#555': 1, '#556': 9, '#557': 4, '#558': 4, '#559': 8, '#560': 5, '#561': 5, '#562': 5, '#563': 5, '#564': 3, '#565': 4, '#566': 9, '#567': 6, '#568': 9, '#569': 8, '#570': 2, '#571': 4, '#572': 1, '#573': 8, '#574': 7, '#575': 9, '#576': 1, '#577': 6, '#578': 3, '#579': 9, '#580': 3, '#581': 5, '#582': 2, '#583': 10, '#584': 10, '#585': 8, '#586': 8, '#587': 1, '#588': 9, '#589': 5, '#590': 10, '#591': 8, '#592': 6, '#593': 4, '#594': 10, '#595': 9, '#596': 8, '#597': 6, '#598': 5, '#599': 7, '#600': 1, '#601': 7, '#602': 8, '#603': 6, '#604': 8, '#605': 8, '#606': 2, '#607': 9, '#608': 4, '#609': 8, '#610': 4, '#611': 4, '#612': 3, '#613': 4, '#614': 10, '#615': 5, '#616': 2, '#617': 8, '#618': 6, '#619': 6, '#620': 8, '#621': 10, '#622': 6, '#623': 3, '#624': 5, '#625': 4, '#626': 5, '#627': 1, '#628': 2, '#629': 2, '#630': 7, '#631': 2, '#632': 6, '#633': 8, '#634': 4, '#635': 10, '#636': 4, '#637': 8, '#638': 3, '#639': 5, '#640': 10, '#641': 6, '#642': 8, '#643': 10, '#644': 6, '#645': 2, '#646': 8, '#647': 10, '#648': 4, '#649': 5, '#650': 1, '#651': 10, '#652': 8, '#653': 1, '#654': 4, '#655': 3, '#656': 8, '#657': 3, '#658': 8, '#659': 9, '#660': 5, '#661': 1, '#662': 6, '#663': 3, '#664': 8, '#665': 7, '#666': 3, '#667': 2, '#668': 4, '#669': 8, '#670': 6, '#671': 2, '#672': 4, '#673': 1, '#674': 1, '#675': 1, '#676': 1, '#677': 10, '#678': 2, '#679': 3, '#680': 4, '#681': 5, '#682': 6, '#683': 7, '#684': 9, '#685': 6, '#686': 4, '#687': 6, '#688': 1, '#689': 2, '#690': 7, '#691': 7, '#692': 8, '#693': 2, '#694': 5, '#695': 8, '#696': 4, '#697': 2, '#698': 8, '#699': 9, '#700': 9, '#701': 9, '#702': 6, '#703': 8, '#704': 4, '#705': 10, '#706': 10, '#707': 9, '#708': 10, '#709': 1, '#710': 7, '#711': 10, '#712': 10, '#713': 4, '#714': 4, '#715': 3, '#716': 3, '#717': 3, '#718': 6, '#719': 8, '#720': 4, '#721': 4, '#722': 3, '#723': 2, '#724': 7, '#725': 3, '#726': 3, '#727': 5, '#728': 4, '#729': 2, '#730': 7, '#731': 8, '#732': 7, '#733': 1, '#734': 2, '#735': 1, '#736': 10, '#737': 8, '#738': 9, '#739': 4, '#740': 8, '#741': 3, '#742': 2, '#743': 10, '#744': 5, '#745': 3, '#746': 8, '#747': 10, '#748': 2, '#749': 5, '#750': 8, '#751': 1, '#752': 3, '#753': 10, '#754': 1, '#755': 10, '#756': 3, '#757': 6, '#758': 4, '#759': 4, '#760': 4, '#761': 6, '#762': 9, '#763': 7, '#764': 8, '#765': 5, '#766': 10, '#767': 4, '#768': 2, '#769': 9, '#770': 5, '#771': 4, '#772': 2, '#773': 5, '#774': 1, '#775': 10, '#776': 4, '#777': 1, '#778': 6, '#779': 7, '#780': 6, '#781': 4, '#782': 5, '#783': 3, '#784': 2, '#785': 8, '#786': 10, '#787': 7, '#788': 3, '#789': 8, '#790': 2, '#791': 8, '#792': 1, '#793': 8, '#794': 9, '#795': 3, '#796': 10, '#797': 4, '#798': 4, '#799': 8, '#800': 10, '#801': 9, '#802': 6, '#803': 5, '#804': 10, '#805': 5, '#806': 6, '#807': 10, '#808': 1, '#809': 8, '#810': 1, '#811': 8, '#812': 8, '#813': 5, '#814': 7, '#815': 2, '#816': 1, '#817': 2, '#818': 8, '#819': 3, '#820': 9, '#821': 2, '#822': 7, '#823': 5, '#824': 7, '#825': 10, '#826': 5, '#827': 4, '#828': 4, '#829': 10, '#830': 2, '#831': 3, '#832': 8, '#833': 7, '#834': 10, '#835': 2, '#836': 4, '#837': 6, '#838': 6, '#839': 3, '#840': 2, '#841': 3, '#842': 4, '#843': 3, '#844': 4, '#845': 4, '#846': 8, '#847': 9, '#848': 10, '#849': 10, '#850': 10, '#851': 3, '#852': 6, '#853': 4, '#854': 6, '#855': 10, '#856': 10, '#857': 1, '#858': 6, '#859': 10, '#860': 3, '#861': 6, '#862': 5, '#863': 6, '#864': 5, '#865': 10, '#866': 8, '#867': 6, '#868': 5, '#869': 7, '#870': 3, '#871': 7, '#872': 3, '#873': 1, '#874': 9, '#875': 6, '#876': 9, '#877': 5, '#878': 1, '#879': 7, '#880': 10, '#881': 9, '#882': 4, '#883': 9, '#884': 3, '#885': 2, '#886': 1, '#887': 10, '#888': 3, '#889': 4, '#890': 5, '#891': 2, '#892': 1, '#893': 2, '#894': 1, '#895': 10, '#896': 9, '#897': 8, '#898': 10, '#899': 2, '#900': 5, '#901': 8, '#902': 6, '#903': 2, '#904': 7, '#905': 8, '#906': 3, '#907': 2, '#908': 8, '#909': 10, '#910': 6, '#911': 10, '#912': 7, '#913': 4, '#914': 4, '#915': 6, '#916': 2, '#917': 4, '#918': 8, '#919': 7, '#920': 1, '#921': 4, '#922': 6, '#923': 8, '#924': 4, '#925': 7, '#926': 3, '#927': 5, '#928': 1, '#929': 2, '#930': 6, '#931': 10, '#932': 9, '#933': 10, '#934': 2, '#935': 4, '#936': 10, '#937': 2, '#938': 8, '#939': 3, '#940': 6, '#941': 2, '#942': 6, '#943': 10, '#944': 1, '#945': 9, '#946': 1, '#947': 1, '#948': 2, '#949': 4, '#950': 1, '#951': 6, '#952': 7, '#953': 7, '#954': 7, '#955': 3, '#956': 9, '#957': 7, '#958': 10, '#959': 1, '#960': 3, '#961': 3, '#962': 3, '#963': 5, '#964': 8, '#965': 9, '#966': 10, '#967': 1, '#968': 5, '#969': 8, '#970': 10, '#971': 8, '#972': 2, '#973': 10, '#974': 10, '#975': 8, '#976': 7, '#977': 3, '#978': 9, '#979': 5, '#980': 9, '#981': 10, '#982': 9, '#983': 4, '#984': 10, '#985': 10, '#986': 9, '#987': 2, '#988': 10, '#989': 2, '#990': 4, '#991': 1, '#992': 3, '#993': 4, '#994': 10, '#995': 5, '#996': 4, '#997': 3, '#998': 8, '#999': 3 }