Files
harbour-core/harbour/website/samples/onidle.prg.html
Viktor Szakats bc49ced49b 2012-11-18 12:55 UTC+0100 Viktor Szakats (harbour syenar.net)
* website/samples/*.*.html
    % pointed compatibility .js link to the project's cloud server
2012-11-18 11:57:56 +00:00

95 lines
2.8 KiB
HTML

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta charset="utf-8">
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/xregexp/2.0.0/xregexp-min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/xregexp/2.0.0/backcompat.js"></script>
<script type="text/javascript" src="/js/shCore.js"></script>
<script type="text/javascript" src="/js/shBrushHarbour.js"></script>
<link href="/css/shCore.css" rel="stylesheet" type="text/css" />
<link href="/css/shThemeDefault.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">SyntaxHighlighter.all()</script>
</head>
<body>
<script type="syntaxhighlighter" class="brush: harbour; light: true"><![CDATA[
#include "hbmemory.ch"
PROCEDURE Main()
LOCAL nH1, nH2, nH3, nH4
LOCAL n := 0
LOCAL aSign := { "|", "/", "-", "\" }
LOCAL nPrev := Seconds()
CLS
? " Time: Memory used: Milliseconds elapsed"
?
? "Can you see it ??? :) Press any key or wait 30 seconds"
?
?
@ 10, 2 SAY "Memory before TEST() call" + Str( Memory( HB_MEM_USED ) )
TEST()
@ 11, 2 SAY "Memory after TEST() and before collecting" + Str( Memory( HB_MEM_USED ) )
hb_gcAll()
@ 12, 2 SAY "Memory after collecting" + Str( Memory( HB_MEM_USED ) )
nH1 := hb_idleAdd( {|| hb_DispOutAt( 0, 1, Time() ) } )
nH2 := hb_idleAdd( {|| TEST(), hb_DispOutAt( 0, 21, Memory( HB_MEM_USED ) ) } )
nH3 := hb_idleAdd( {|| iif( n == 4, n := 1, n++ ), hb_DispOutAt( 0, 41, aSign[ n ] ) } )
nH4 := hb_idleAdd( {|| hb_DispOutAt( 0, 61, 1000 * ( Seconds() - nPrev ) ), nPrev := Seconds() } )
? ValType( nH1 ), nH1, ValType( nH2 ), nH2, ValType( nH3 ), nH3, ValType( nH4 ), nH4
Inkey( 30 )
IF ! Empty( nH3 )
@ 14, 2 SAY "Delete task 3: " + hb_ValToStr( nH3 )
hb_idleDel( nH3 )
ENDIF
IF ! Empty( nH2 )
@ 15, 2 SAY "Delete task 2: " + hb_ValToStr( nH2 )
hb_idleDel( nH2 )
ENDIF
IF ! Empty( nH1 )
@ 16, 2 SAY "Delete task 1: " + hb_ValToStr( nH1 )
hb_idleDel( nH1 )
ENDIF
IF ! Empty( nH4 )
@ 17, 2 SAY "Delete task 4: " + hb_ValToStr( nH4 )
hb_idleDel( nH4 )
ENDIF
@ 18, 2 SAY "Memory after idle states" + Str( Memory( HB_MEM_USED ) )
hb_gcAll()
@ 19, 2 SAY "Memory after collecting" + Str( Memory( HB_MEM_USED ) )
RETURN
PROCEDURE TEST()
LOCAL a, b, c
LOCAL cb
a := Array( 3 )
b := Array( 3 )
c := Array( 3 )
a[ 1 ] := a
a[ 2 ] := b
a[ 3 ] := c
b[ 1 ] := a
b[ 2 ] := b
b[ 3 ] := c
c[ 1 ] := a
c[ 2 ] := b
c[ 3 ] := c
cb := {| x | x := cb }
Eval( cb )
RETURN
]]></script>
</body>
</html>