Page 1 of 2

Network Throuput

Posted: Tue Jun 07, 2005 9:52 pm
by Droopy
This code need my Lib ( Droopy Lib )

At first launch it ask you the souce file and the destination file
( Parameters are stored in an Ini file in the same directory as the exe )

[img]http://purebasic.myftp.org/files/67/Déb ... ughput.JPG[/img]

The source code and the soft is in the Zip File

DOWNLOAD

Code: Select all

; PureBasic 3.93
; Droopy 06/06/05

;{- Constantes
#Moyen=1.5
#Haut=3
#Full=10
#NbDeBarres=44
#TailleFichierMin=100001 ; 1Mo
#TaileLectureEcriture=100000
;}

;{- Si fichier INI absent le créer / Sinon le lire
If FileSize(GetProgramPath()+"Débit Réseau.ini")=-1
  Repeat ;/ Si fichier de lecture trop petit on redemande un autre fichier
    FichierLecture.s=OpenFileRequester("Source File","","All files|*.*",0)
    If FileSize(FichierLecture)<#TailleFichierMin
      MessageRequester("Source File too small","Min "+Str(#TailleFichierMin)+" byte")
    EndIf
  Until FileSize(FichierLecture)>#TailleFichierMin
  ;/ Demande le fichier de destination
  FichierEcriture.s=OpenFileRequester("Destination File","","All Files|*.*",0)
  IniWrite(GetProgramPath()+"Débit Réseau.ini","Config","Lecture",FichierLecture)
  IniWrite(GetProgramPath()+"Débit Réseau.ini","Config","Ecriture",FichierEcriture)
Else
  ;/ Fichier INI absent --> On le créé / Stocke les préférences
  FichierLecture.s=IniRead(GetProgramPath()+"Débit Réseau.ini","Config","Lecture")
  FichierEcriture.s=IniRead(GetProgramPath()+"Débit Réseau.ini","Config","Ecriture")
EndIf
;}
  
;{- Source et Destination accessible sinon quitte
If FileSize(FichierLecture)=-1
  MessageRequester("Source File not Found",FichierLecture,#MB_ICONERROR)
  End
EndIf
If GetDiskFreeSpaceEx(Left(FichierEcriture,2))=0
  MessageRequester("Missing Destination",Left(FichierEcriture,2),#MB_ICONERROR)
  End
EndIf
;}

Enumeration ;- Des Gadgets
  #Cadre1
  #Cadre2
  #Lecture
  #Ecriture
  #GraphLecture
  #GraphEcriture
EndEnumeration

;{- Son début
Son=InitSound() 
If Son <>0
  CatchSound(0, ?Son)
  PlaySound(0,0)
EndIf
;}

;{- Visuel
Handle=OpenWindow(0, 216, 0, 510, 302,  #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_TitleBar | #PB_Window_Invisible , "Network Throughput")
SetWindowsTransparency(Handle,0)
HideWindow(0,0)
CreateGadgetList(WindowID())
TextGadget(#Cadre1, 10, 10, 240, 20, "Read",#PB_Text_Center)
TextGadget(#Cadre2, 260, 10, 240, 20, "Write",#PB_Text_Center)
TextGadget(#Lecture, 10, 250, 240, 20, "",#PB_Text_Center )
TextGadget(#Ecriture, 260, 250, 240, 20, "",#PB_Text_Center )
GraphLecture=Graph(20, 30, 220, 200, #NbDeBarres,#Moyen,#Haut,#Full,255,65535,65280,0)
GraphEcriture=Graph(270, 30, 220, 200 ,#NbDeBarres,#Moyen,#Haut,#Full,255,65535,65280,0)
CreateStatusBar(0,WindowID(0))
AddStatusBarField(255)
AddStatusBarField(255)
;/ Fade in
For n= 1 To 255 Step 6
  SetWindowsTransparency(WindowID(0),n)
  Delay(1)
Next n
;}    

*Tampon=AllocateMemory(#TaileLectureEcriture)

Repeat

  If totoro>250  
    totoro=0
    
  ;{/ Mesure & Calcul du débit en Lecture
  OpenFile(0,FichierLecture)
  CreateFile(1,GetEnvironmentVariable("temp")+"\TestDebit.tst")
  UseFile(0)
  MeasureHiResIntervalStart()
  ReadData(*Tampon,#TaileLectureEcriture)
  UseFile(1)
  WriteData(*Tampon,#TaileLectureEcriture)
  TempsDeLecture.f=MeasureHiResIntervalStop()
  DebitLecture.f=#TaileLectureEcriture/TempsDeLecture
  DebitLecture/1024/1024 ; Converit le débit en Mo / s
  CloseFile(0)
  CloseFile(1)
  DeleteFile(GetEnvironmentVariable("temp")+"\TestDebit.tst")
  ;}
  
  ;{/ Mesure & Calcul du débit en Ecriture
  CreateFile(0,FichierEcriture)
  MeasureHiResIntervalStart()
  WriteData(*Tampon,#TaileLectureEcriture)
  TempsEcriture.f=MeasureHiResIntervalStop()
  DebitEcriture.f=#TaileLectureEcriture/TempsEcriture
  DebitEcriture/1024/1024 ; Converit le débit en Mo / s
  CloseFile(0)
  DeleteFile(FichierEcriture)
  ;}
  
  ;{/ Ecriture dans les GadgetText
  SetGadgetText(#Lecture,StrF(DebitLecture,3)+" Mb/s")
  SetGadgetText(#Ecriture,StrF(DebitEcriture,3)+" Mb/s")
  ;}
  
  ;{/ Ecriture dans la Status Bar ( Maj Moyenne )
  MoyLecture.f+DebitLecture
  MoyEcriture.f+DebitEcriture
  NbDeFois+1
  temp1.s=" Read Average "+StrF((MoyLecture/NbDeFois),2)+" Mb/s"
  temp2.s=" Write Average "+StrF((MoyEcriture/NbDeFois),2)+" Mb/s"
  StatusBarText(0,0,temp1)
  StatusBarText(0,1,temp2)
  ;}
  
  ;{/ Ecriture des Graphs
  GraphSet(GraphLecture,DebitLecture)
  GraphSet(GraphEcriture,DebitEcriture)
  ;}

  EndIf

  Delay(1)
  totoro+1

  ;/ Affichage du nombre d'échantillons dans la barre de titres
  SetWindowTitle(0,"Network Throughput ( "+Str(NbDeFois)+" Samples )")

a=WindowEvent()
Until a=#PB_Event_CloseWindow 

;/ Son fin
If Son <>0
  PlaySound(0,0)
EndIf

;{/ On quitte ( Libération des ressources & Fade Out
FreeMemory(*Tampon)
For n= 255 To 0 Step -3
  SetWindowsTransparency(Handle,n)
  Delay(1)
Next n
;}


DataSection
Son: IncludeBinary "Débit Réseau.wav"
EndDataSection

Posted: Wed Jun 08, 2005 10:05 am
by Pantcho!!
nice! this is very good for people who are programming servers and want to see the traffic.

thanks.

Posted: Wed Jun 08, 2005 10:52 am
by GeoTrail
Very nice Droopy.
Btw, what's your connection speed? :shock:

Posted: Wed Jun 08, 2005 11:49 am
by Droopy
I have 512K ADSL

But this soft is for monitoring Local network throughput ( 100Mb )

Posted: Wed Jun 08, 2005 11:58 am
by GeoTrail
Aaaa started to wonder abit there ;)

Posted: Wed Jun 08, 2005 12:50 pm
by thefool
the zip file seems to be corrupted for me!
i have tried using 2 different browsers but that didnt work either...

Posted: Wed Jun 08, 2005 12:53 pm
by Droopy
I check the archive and seems valid :shock:

Try : http://www.penguinbyte.com/apps/pbwebst ... ughput.zip

Posted: Wed Jun 08, 2005 12:56 pm
by Hatonastick
I tried downloading the file and instead ended up with the following html:
<br />
<b>Warning</b>: readfile(): Unable to access files/67/Débit_Réseau/Network_Throughput.zip in <b>/home/virtual/site1/fst/var/www/html/apps/pbwebstor/index.php</b> on line <b>20</b><br />
<br />
<b>Warning</b>: readfile(files/67/Débit_Réseau/Network_Throughput.zip): failed to open stream: No such file or directory in <b>/home/virtual/site1/fst/var/www/html/apps/pbwebstor/index.php</b> on line <b>20</b><br />

Posted: Wed Jun 08, 2005 1:07 pm
by GeoTrail
Works fine here.

;)
Image

Posted: Wed Jun 08, 2005 1:28 pm
by thefool
still doesnt work :(

Posted: Wed Jun 08, 2005 2:44 pm
by Droopy

Posted: Wed Jun 08, 2005 4:14 pm
by Killswitch
Could you translate this into English please? I'm very interested in using it!

Posted: Wed Jun 08, 2005 4:30 pm
by traumatic

Posted: Wed Jun 08, 2005 7:25 pm
by Droopy

Posted: Wed Jun 08, 2005 7:39 pm
by traumatic
:D