Rate counter: Difference between revisions

Rate counter en FreeBASIC
m (→‎{{header|Phix}}: added syntax colouring the hard way)
(Rate counter en FreeBASIC)
Line 750:
 
For another approach, imagine a long-running program, WORKER, that writes various remarks to standard output as it goes, and consider another, TIMESTAMP, that copies from standard input to standard output, prefixing each line with a date and time stamp, perhaps invoked via something like <code>WORKER | TIMESTAMP >Log.txt</code> - the vertical bar an amusing choice to symbolise a horizontal "pipe". When everything finishes, the log file can be analysed to determine the rate of progress. But alas, in the windows world, the stages of a "pipeline" are performed serially, not simultaneously - the vertical bar symbolising this separation. All output from WORKER will be saved in a temporary disc file then when WORKER finishes that file will be fed as input to TIMESTAMP, thereby producing data only on the rate of file input/output.
 
 
=={{header|FreeBASIC}}==
{{trans|BaCon}}
<lang freebasic>
Dim Shared As Integer i
 
Sub timeit
Dim As Integer iter = 0
Dim As Double starter = Timer
While True
iter += 1
If Timer >= starter + i Then Exit While
Wend
Print iter; " iteraciones en"; i; " milisegundo"; Iif(i > 1, "s", "")
End Sub
 
For i = 1 To 3
timeit
Next i
 
i = 200 : timeit
Sleep
</lang>
{{out}}
<pre>
44804265 iteraciones en 1 milisegundo
91122566 iteraciones en 2 milisegundos
137725199 iteraciones en 3 milisegundos
8426682089 iteraciones en 200 milisegundos
</pre>
 
 
=={{header|Go}}==
2,167

edits