Files
harbour-core/contrib/hblzf/tests/test2.prg
vszakats 9687850865 2013-03-16 02:10 UTC+0100 Viktor Szakats (harbour syenar.net)
* (all files)
    * stripped svn header
    * minor cleanups
    ; use following command to find out the history of files:
       git log
       git log --follow
       git blame
       git annotate
2013-03-16 02:11:42 +01:00

55 lines
1.3 KiB
Plaintext

#require "hbbz2"
#require "hblzf"
#define _NREPL_ 50
PROCEDURE Main()
LOCAL cStr := Replicate( hb_MemoRead( hb_argv( 0 ) ), _NREPL_ )
LOCAL aCompressedData := { NIL, NIL, NIL, NIL }
LOCAL hFuncs := { ;
"GZIP" => @hb_gzCompress(), ;
"ZLIB" => @hb_ZCompress(), ;
"BZ2 " => @hb_bz2_Compress(), ;
"LZF " => @hb_lzf_compress();
}
LOCAL hFuncs2 := { ;
"GZIP" => @hb_ZUncompress(), ;
"ZLIB" => @hb_ZUncompress(), ;
"BZ2 " => @hb_bz2_Uncompress(), ;
"LZF " => @hb_lzf_decompress();
}
MakeTest( @hFuncs, @aCompressedData, @cStr )
MakeTest( @hFuncs2, @aCompressedData )
RETURN
STATIC PROCEDURE MakeTest( ... )
LOCAL e, e2, cRes, cFmt
LOCAL nResult := 0
LOCAL nBegin, nEnd
LOCAL lCmp := ( PCount() > 2 )
FOR EACH e, e2 IN hb_PValue( 1 ), hb_PValue( 2 )
nBegin := hb_SecondsCPU()
cRes := Eval( e:__enumValue(), iif( lCmp, hb_PValue( 3 ), e2 ), NIL, @nResult )
nEnd := hb_SecondsCPU()
IF lCmp
e2 := cRes
ENDIF
cFmt := hb_StrFormat( ;
"%s: %d -> %d, Ratio %.2f%%, Times %.2f", ;
e:__enumKey(), ;
Len( iif( lCmp, hb_PValue( 3 ), e2 ) ), Len( cRes ), ;
( Len( cRes ) / Len( iif( lCmp, hb_PValue( 3 ), e2 ) ) ) * 100, ;
nEnd - nBegin;
)
? cFmt
NEXT
?
RETURN