Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | "Mel Smith" <med_cutout_syntel@aol.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Speed Test for Comparison |
| Date | 2011-12-10 11:28 -0700 |
| Message-ID | <9khmneF4udU1@mid.individual.net> (permalink) |
| References | <9kc99pFurU1@mid.individual.net> <lnty5ak6vk.fsf@nuthaus.mib.org> |
Hi:
I have extracted Test 019 (T019) from the test suite, and have recoded
part of it to show the translation and compilation sequence to .C code
and at the bottom of this post I have include the Harbour source code for
the test
-Mel Smith
***** following is the C code for Test 019 (T019) **********
This test took approx 1.52 seconds on my machine noted above
/*
* Harbour 3.1.0dev (Rev. 17129)
* MinGW GNU C 4.6.1 (32-bit)
* Generated C source from "source\T019.prg"
*/
#include "hbvmpub.h"
#include "hbpcode.h"
#include "hbinit.h"
#include "hbxvm.h"
HB_FUNC( MAIN );
HB_FUNC_EXTERN( SCROLL );
HB_FUNC_EXTERN( SETPOS );
HB_FUNC( T019 );
HB_FUNC_EXTERN( QOUT );
HB_FUNC_EXTERN( STR );
HB_FUNC_EXTERN( INKEY );
HB_FUNC_EXTERN( HB_SECONDSCPU );
HB_FUNC_EXTERN( PROCNAME );
HB_INIT_SYMBOLS_BEGIN( hb_vm_SymbolInit_T019 )
{ "MAIN", {HB_FS_PUBLIC | HB_FS_FIRST | HB_FS_LOCAL}, {HB_FUNCNAME( MAIN )},
NULL },
{ "SCROLL", {HB_FS_PUBLIC}, {HB_FUNCNAME( SCROLL )}, NULL },
{ "SETPOS", {HB_FS_PUBLIC}, {HB_FUNCNAME( SETPOS )}, NULL },
{ "T019", {HB_FS_PUBLIC | HB_FS_LOCAL}, {HB_FUNCNAME( T019 )}, NULL },
{ "QOUT", {HB_FS_PUBLIC}, {HB_FUNCNAME( QOUT )}, NULL },
{ "STR", {HB_FS_PUBLIC}, {HB_FUNCNAME( STR )}, NULL },
{ "INKEY", {HB_FS_PUBLIC}, {HB_FUNCNAME( INKEY )}, NULL },
{ "HB_SECONDSCPU", {HB_FS_PUBLIC}, {HB_FUNCNAME( HB_SECONDSCPU )}, NULL },
{ "PROCNAME", {HB_FS_PUBLIC}, {HB_FUNCNAME( PROCNAME )}, NULL }
HB_INIT_SYMBOLS_EX_END( hb_vm_SymbolInit_T019, "source\\T019.prg", 0x0,
0x0003 )
#if defined( HB_PRAGMA_STARTUP )
#pragma startup hb_vm_SymbolInit_T019
#elif defined( HB_DATASEG_STARTUP )
#define HB_DATASEG_BODY HB_DATASEG_FUNC( hb_vm_SymbolInit_T019 )
#include "hbiniseg.h"
#endif
HB_FUNC( MAIN )
{
do {
hb_xvmFrame( 1, 0 );
hb_xvmSetLine( 5 );
hb_xvmPushFuncSymbol( symbols + 1 );
if( hb_xvmDo( 0 ) ) break;
hb_xvmPushFuncSymbol( symbols + 2 );
hb_xvmPushInteger( 0 );
hb_xvmPushInteger( 0 );
if( hb_xvmDo( 2 ) ) break;
hb_xvmSetLine( 8 );
hb_xvmPushFuncSymbol( symbols + 3 );
if( hb_xvmFunction( 0 ) ) break;
hb_xvmPopLocal( 1 );
hb_xvmSetLine( 17 );
hb_xvmPushFuncSymbol( symbols + 4 );
hb_xvmPushLocal( 1 );
if( hb_xvmArrayItemPush( 1 ) ) break;
hb_xvmPushStringConst( " *** ", 5 );
if( hb_xvmPlus() ) break;
hb_xvmPushFuncSymbol( symbols + 5 );
hb_xvmPushLocal( 1 );
if( hb_xvmArrayItemPush( 2 ) ) break;
hb_xvmPushInteger( 5 );
hb_xvmPushInteger( 2 );
if( hb_xvmFunction( 3 ) ) break;
if( hb_xvmPlus() ) break;
if( hb_xvmDo( 1 ) ) break;
hb_xvmSetLine( 20 );
hb_xvmPushFuncSymbol( symbols + 4 );
if( hb_xvmDo( 0 ) ) break;
hb_xvmSetLine( 21 );
hb_xvmPushFuncSymbol( symbols + 4 );
hb_xvmPushStringConst( "Press any Key to Exit: ", 23 );
if( hb_xvmDo( 1 ) ) break;
hb_xvmSetLine( 22 );
hb_xvmPushFuncSymbol( symbols + 6 );
hb_xvmPushInteger( 0 );
if( hb_xvmDo( 1 ) ) break;
hb_xvmSetLine( 23 );
hb_xvmRetNil();
/* *** END PROC *** */
} while( 0 );
}
HB_FUNC( T019 )
{
HB_BOOL fValue;
do {
hb_xvmFrame( 2, 0 );
hb_xvmSetLine( 30 );
hb_xvmPushNil();
hb_xvmPopLocal( 2 );
hb_xvmSetLine( 31 );
hb_xvmPushFuncSymbol( symbols + 7 );
if( hb_xvmFunction( 0 ) ) break;
hb_xvmPopLocal( 1 );
hb_xvmSetLine( 33 );
hb_xvmPushInteger( 1 );
hb_xvmPushUnRef();
hb_xvmPopLocal( 2 );
goto lab00002;
lab00001: ;
hb_xvmSetLine( 34 );
hb_xvmPushFuncSymbol( symbols + 5 );
hb_xvmPushLocal( 2 );
if( hb_xvmDivideByInt( 1000 ) ) break;
if( hb_xvmDo( 1 ) ) break;
hb_xvmSetLine( 33 );
if( hb_xvmLocalIncPush( 2 ) ) break;
lab00002: ;
if( hb_xvmGreaterThenIntIs( 1000000, &fValue ) ) break;
if( !fValue )
goto lab00001;
hb_xvmSetLine( 37 );
hb_xvmPushFuncSymbol( symbols + 7 );
if( hb_xvmFunction( 0 ) ) break;
hb_xvmPushLocal( 1 );
if( hb_xvmMinus() ) break;
hb_xvmPopLocal( 1 );
hb_xvmSetLine( 43 );
hb_xvmPushFuncSymbol( symbols + 8 );
if( hb_xvmFunction( 0 ) ) break;
hb_xvmPushStringConst( ": ", 2 );
if( hb_xvmPlus() ) break;
hb_xvmPushStringConst( "str(i/1000)", 11 );
if( hb_xvmPlus() ) break;
hb_xvmPushLocal( 1 );
hb_xvmArrayGen( 2 );
hb_xvmRetValue();
/* *** END PROC *** */
} while( 0 );
}
**************** end of C code **********************
************************************************************
Following is the harbour code that generated the C Code above
function main()
local aResult
// clear the screen
CLS
// then call the Test Function T019
aResult := T019()
// Now Print the results to the Screen:
// (The question mark '?') skips a line and print the String Expression
// to its right)
// 1st element is a character string
// 2nd element must be converted from a numeric to a character string
// so that it can be printed. The format here has two decimals
? aResult[1] + " *** " + str(aResult[2],5,2)
// wait for a key press before exiting
?
? "Press any Key to Exit: "
inkey(0)
return nil
// Here is the test function for making a string of an real number
// after taking an incremented integer and dividing it by 1000,
// and doing this 1,000,000 times
function T019()
local time, i:= nil
time = hb_secondscpu() // get the cpu seconds to this moment for this app
for i := 1 to 1000000
str( i / 1000 ) // no assignment of the return value
next
time := hb_secondscpu() - time // compute cpu seconds used
// now return a 2-element array containing
// 1. The Procedure Name and the Expression to be analyzed
// 2. The time in decimal seconds taken to run the loop
return { procname() + ": " + 'str(i/1000)', time }
************* end of Harbour Code **********
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Speed Test for Comparison "Mel Smith" <med_cutout_syntel@aol.com> - 2011-12-08 10:09 -0700
Re: Speed Test for Comparison Richard Sanders <lnr729@gmail.com> - 2011-12-08 11:19 -0800
Re: Speed Test for Comparison "Mel Smith" <med_cutout_syntel@aol.com> - 2011-12-08 13:13 -0700
Re: Speed Test for Comparison "Mel Smith" <med_cutout_syntel@aol.com> - 2011-12-08 13:18 -0700
Re: Speed Test for Comparison Seebs <usenet-nospam@seebs.net> - 2011-12-08 20:41 +0000
Re: Speed Test for Comparison Ben Pfaff <blp@cs.stanford.edu> - 2011-12-08 12:49 -0800
Re: Speed Test for Comparison Seebs <usenet-nospam@seebs.net> - 2011-12-08 21:53 +0000
Re: Speed Test for Comparison Seebs <usenet-nospam@seebs.net> - 2011-12-08 20:41 +0000
Re: Speed Test for Comparison "BartC" <bc@freeuk.com> - 2011-12-08 21:43 +0000
Re: Speed Test for Comparison ImpalerCore <jadill33@gmail.com> - 2011-12-08 13:58 -0800
Re: Speed Test for Comparison Keith Thompson <kst-u@mib.org> - 2011-12-08 14:58 -0800
Re: Speed Test for Comparison "Mel Smith" <med_cutout_syntel@aol.com> - 2011-12-10 11:28 -0700
Re: Speed Test for Comparison "BartC" <bc@freeuk.com> - 2011-12-10 21:40 +0000
Re: Speed Test for Comparison "Mel Smith" <med_cutout_syntel@aol.com> - 2011-12-10 19:26 -0700
Re: Speed Test for Comparison Keith Thompson <kst-u@mib.org> - 2011-12-10 13:49 -0800
csiph-web