[fpc-devel] Faster Implementation for IntToStr
Amir
amir at aavani.net
Sun Sep 2 09:37:46 CEST 2012
Hi,
In one of my project, I have to call IntToStr more than 10M times. I
noticed that IntToStr calls Str function. I implemented my own version
of IntToStr which is almost twice faster than the current implementation
of IntToStr. I wonder if it is possible to use my code in IntToStr function.
I attached my function, and also a sample code which calls MyIntToStr
and IntToStr 1000 times. I used valgrind to compare the performance of
the two function.
Amir
P.S. I understand that my code is not easy to read/understand, but the
question is, should the code for a library be readable/easy to understand?
P.S. I compiled the project using
fpc -Sd -O3 IntToStr.lpr
-------------- next part --------------
version: 1
creator: callgrind-3.7.0
pid: 15863
cmd: ./IntToStr
part: 1
desc: I1 cache:
desc: D1 cache:
desc: LL cache:
desc: Timerange: Basic block 0 - 376150
desc: Trigger: Program termination
positions: line
events: Ir
summary: 2189171
ob=(1) /home/Amir/Desktop/Temp/Amir/Code/IntToStr
fl=(2) /home/Amir/Desktop/Temp/Amir/Code//IntToStr.lpr
fn=(2) main
89 7
cfi=(1) ???
cfn=(4) fpc_initializeunits
calls=1 -89
* 64793
* 7
cfi=(1)
cfn=(142) fpc_pushexceptaddr
calls=1 -89
* 24
* 2
cfi=(1)
cfn=(144) fpc_setjmp
calls=1 -89
* 12
* 3
+1 4
+2 2
cfi=(1)
cfn=(228) SYSTEM_RANDOM$LONGINT$$LONGINT
calls=1 -92
* 33740
-2 1000
+2 2000
cfi=(1)
cfn=(228)
calls=1000 -92
* 68837
* 1001
+1 1001
cfi=(1)
cfn=(234) fpc_get_output
calls=1001 -93
* 9009
* 3003
cfi=(1)
cfn=(152) fpc_ansistr_decr_ref
calls=1001 -93
* 118009
* 4004
cfi=(1)
cfn=(236) SYSUTILS_INTTOSTR$LONGINT$$ANSISTRING
calls=1001 -93
* 631621
* 4004
cfi=(1)
cfn=(250) fpc_write_text_ansistr
calls=1001 -93
* 142564
* 1001
cfi=(1)
cfn=(254) fpc_iocheck
calls=1001 -93
* 13013
* 2002
cfi=(1)
cfn=(256) fpc_writeln_end
calls=1001 -93
* 180180
* 1001
cfi=(1)
cfn=(254)
calls=1001 -93
* 13013
+1 1001
cfi=(1)
cfn=(234)
calls=1001 -94
* 9009
* 3003
cfi=(1)
cfn=(152)
calls=1001 -94
* 118118
* 4004
cfn=(272) P$INTTOSTR_MYINTTOSTR$LONGINT$$ANSISTRING
calls=1001 -43
* 340011
* 4004
cfi=(1)
cfn=(250)
calls=1001 -94
* 142564
* 1001
cfi=(1)
cfn=(254)
calls=1001 -94
* 13013
* 2002
cfi=(1)
cfn=(256)
calls=1001 -94
* 180180
* 1001
cfi=(1)
cfn=(254)
calls=1001 -94
* 13013
-4 2003
cfi=(1)
cfn=(148) fpc_popaddrstack
calls=1 -90
* 17
+7 2
cfi=(1)
cfn=(152)
calls=1 -97
* 118
* 5
cfi=(1)
cfn=(274) SYSTEM_DO_EXIT
calls=1 -97
* 60231
fn=(272)
51 6006
+1 3003
+7 1001
+2 3003
+3 1001
+2 3003
+1 1064
+3 4173
-1 23210
+3 3003
cfi=(1)
cfn=(244) fpc_ansistr_setlength
calls=1001 -72
* 135135
+1 5005
+2 1001
+2 56958
+1 47465
+1 9493
-4 31482
+8 5005
fl=(1)
fn=(12) SYSTEM_init
0 3
cfn=(8) SYSTEM_SYSRESETFPU
calls=1 0
0 22
0 5
cfn=(10) SYSTEM_SYSINITFPU
calls=1 0
0 20
0 5
cfn=(14) SYSTEM_CHECKINITIALSTKLEN$QWORD$$QWORD
calls=1 0
0 74
0 27
cfn=(22) SYSTEM_INSTALLSIGNALS
calls=1 0
0 395
0 1
cfn=(30) SYSTEM_INITHEAP
calls=1 0
0 184
0 1
cfn=(32) SYSTEM_SYSINITEXCEPTIONS
calls=1 0
0 17
0 1
cfn=(34) SYSTEM_SYSINITSTDIO
calls=1 0
0 1395
0 1
cfn=(48) SYSTEM_SYSINITEXECPATH
calls=1 0
0 39
0 8
cfn=(52) SYSTEM_INITSYSTEMTHREADS
calls=1 0
0 188
0 1
cfn=(58) SYSTEM_INITVARIANTMANAGER
calls=1 0
0 1
0 1
cfn=(60) SYSTEM_INITUNICODESTRINGMANAGER
calls=1 0
0 43
0 6
fn=(30)
0 14
cfn=(16) SYSTEM_FILLCHAR$formal$INT64$BYTE
calls=1 0
0 80
0 7
cfn=(16)
calls=1 0
0 80
0 3
fn=(74) SYSTEM_FPOPEN$PCHAR$LONGINT$LONGINT$$LONGINT
0 16
cfn=(46) SYSTEM_FPSYSCALL$INT64$INT64$INT64$INT64$$INT64
calls=2 0
0 24
0 4
fn=(154) SYSTEM_TOBJECT_$__AFTERCONSTRUCTION
0 12
fn=(156) SYSUTILS_INITINTERNATIONAL
0 2
cfn=(158) SYSUTILS_INITINTERNATIONALGENERIC
calls=1 0
0 96
0 1
cfn=(160) SYSUTILS_INITANSI
calls=1 0
0 2866
0 2
fn=(174) SYSTEM_NORTLEVENTCREATE$$PRTLEVENT
0 27
fn=(178) SYSTEM_NOGETCURRENTTHREADID$$QWORD
0 15
fn=(188) SYSTEM_INITINTERFACEPOINTERS$TCLASS$POINTER
0 63
fn=(196) SYSTEM_BASICEVENTCREATE$POINTER$BOOLEAN$BOOLEAN$ANSISTRING$$POINTER
0 8
cfn=(198) SYSTEM_NOBASICEVENTCREATE$POINTER$BOOLEAN$BOOLEAN$ANSISTRING$$POINTER
calls=1 0
0 10
0 2
fn=(198)
0 10
fn=(228)
0 7007
cfn=(230) SYSTEM_GENRAND_MT19937$$LONGINT
calls=1001 0
0 88563
0 7007
fn=(254)
0 52052
fn=(256)
0 54054
cfn=(252) SYSTEM_FPC_WRITEBUFFER$TEXT$formal$INT64
calls=2002 0
0 110110
0 12012
cfn=(258) SYSTEM_FILEWRITEFUNC$TEXTREC
calls=2002 0
0 176176
0 8008
fn=(314) SYSUTILS_FREEANDNIL$formal
0 20
cfn=(304) SYSTEM_TOBJECT_$__FREE
calls=1 0
0 7
cfn=(305) SYSTEM_TOBJECT_$__FREE'2
calls=3 0
0 742
0 8
fn=(350) SYSTEM_TINTERFACEDOBJECT_$__BEFOREDESTRUCTION
0 6
fn=(374) SYSUTILS_finalize
0 2
cfn=(376) SYSUTILS_FREEDRIVESTR
calls=1 0
0 192
0 1
cfn=(378) SYSUTILS_DONEEXCEPTIONS
calls=1 0
0 503
0 3
cfn=(336) fpc_finalize
calls=1 0
0 2260
0 2
cfn=(152)
calls=1 0
0 14
0 4
cfn=(152)
calls=1 0
0 14
0 4
cfn=(152)
calls=1 0
0 9
0 4
cfn=(384) fpc_unicodestr_decr_ref
calls=1 0
0 9
0 5
cfn=(336)
calls=1 0
0 61
0 3
cfn=(336)
calls=1 0
0 61
0 2
cfn=(152)
calls=1 0
0 14
0 4
cfn=(152)
calls=1 0
0 9
0 4
fn=(382) SYSTEM_RECORDRTTI$POINTER$POINTER$TRTTIPROC
0 27
cfn=(337) fpc_finalize'2
calls=1 0
0 34
0 60
cfn=(337)
calls=10 0
0 2066
0 40
fn=(392) SYSTEM_FREE_OSCHUNK$PFREELISTS$POSCHUNK
0 35
cfn=(394) SYSTEM_REMOVE_FREED_FIXED_CHUNKS$POSCHUNK
calls=5 0
0 37591
0 97
cfn=(396) SYSTEM_SYSOSFREE$POINTER$QWORD
calls=5 0
0 110
0 20
fn=(396)
0 10
cfn=(398) SYSTEM_FPMUNMAP$POINTER$QWORD$$LONGINT
calls=5 0
0 90
0 10
fn=(4)
0 4
cfn=(6) SYSTEM_FPC_CPUINIT
calls=1 0
0 54
0 67
cfn=(164) CLASSES_init
calls=1 0
0 11127
cfn=(162) TYPINFO_init_implicit
calls=1 0
0 3
cfn=(132) SYSUTILS_init
calls=1 0
0 3920
cfn=(62) UNIX_init
calls=1 0
0 47149
cfn=(12)
calls=1 0
0 2438
0 31
fn=(46)
0 24132
fn=(68) BASEUNIX_FPOPEN$SHORTSTRING$LONGINT$$LONGINT
0 16
cfn=(70) SYSTEM_FPC_SHORTSTR_ASSIGN$LONGINT$POINTER$POINTER
calls=2 0
0 149
0 10
cfn=(72) fpc_shortstr_concat
calls=2 0
0 124
0 8
cfn=(74)
calls=2 0
0 44
0 6
fn=(78) SYSTEM_FPREAD$LONGINT$PCHAR$QWORD$$INT64
0 12
cfn=(46)
calls=2 0
0 24
0 4
fn=(106) SYSTEM_SYSGETMEM$QWORD$$POINTER
0 32320
cfn=(108) SYSTEM_SYSGETMEM_FIXED$QWORD$$POINTER
calls=2020 0
0 172254
0 14140
fn=(126) UNIX_GETLOCALTIMEZONE$LONGINT
0 4
cfn=(128) UNIX_GETLOCALTIMEZONE$LONGINT$LONGINT$LONGINT
calls=1 0
0 693
0 2
fn=(144)
0 12408
fn=(184) SYSUTILS_TMULTIREADEXCLUSIVEWRITESYNCHRONIZER_$__CREATE$$TMULTIREADEXCLUSIVEWRITESYNCHRONIZER
0 13
cfn=(186) SYSTEM_TINTERFACEDOBJECT_$__NEWINSTANCE$$TOBJECT
calls=1 0
0 252
0 8
cfn=(142)
calls=1 0
0 24
0 2
cfn=(144)
calls=1 0
0 12
0 7
cfn=(142)
calls=1 0
0 24
0 2
cfn=(144)
calls=1 0
0 12
0 5
cfn=(168) SYSTEM_INITCRITICALSECTION$TRTLCRITICALSECTION
calls=1 0
0 14
0 1
cfn=(172) SYSTEM_RTLEVENTCREATE$$PRTLEVENT
calls=1 0
0 15
0 3
cfn=(190) SYSTEM_RTLEVENTRESETEVENT$PRTLEVENT
calls=1 0
0 14
0 3
cfn=(194) SYSTEM_INTERLOCKEDEXCHANGE$LONGINT$LONGINT$$LONGINT
calls=1 0
0 7
0 3
cfn=(194)
calls=1 0
0 7
0 5
cfn=(196)
calls=1 0
0 20
0 2
cfn=(148)
calls=1 0
0 17
0 13
cfn=(200) SYSTEM_TINTERFACEDOBJECT_$__AFTERCONSTRUCTION
calls=1 0
0 15
0 1
cfn=(148)
calls=1 0
0 17
0 8
fn=(192) SYSTEM_NORTLEVENTRESETEVENT$PRTLEVENT
0 16
fn=(194)
0 21
fn=(208) SYSTEM_TINTERFACEDOBJECT_$___ADDREF$$LONGINT
0 3
cfn=(210) SYSTEM_INTERLOCKEDINCREMENT$LONGINT$$LONGINT
calls=1 0
0 10
0 2
fn=(226) CLASSES_TLIST_$__NOTIFY$POINTER$TLISTNOTIFICATION
0 2
fn=(236)
0 11011
cfn=(142)
calls=1001 0
0 24024
0 2002
cfn=(144)
calls=1001 0
0 12012
0 8008
cfn=(238) fpc_shortstr_sint
calls=1001 0
0 276881
0 2002
cfn=(152)
calls=1001 0
0 9009
0 4004
cfn=(242) fpc_shortstr_to_ansistr
calls=1001 0
0 191577
0 2002
cfn=(150) fpc_ansistr_incr_ref
calls=1001 0
0 21021
0 3003
cfn=(152)
calls=1001 0
0 9009
0 3003
cfn=(148)
calls=1001 0
0 17017
0 2002
cfn=(152)
calls=1001 0
0 27027
0 7007
fn=(238)
0 10010
cfn=(240) SYSTEM_INT_STR$INT64$OPENSTRING
calls=1001 0
0 258863
0 8008
fn=(284) WRPR_SYSUTILS_TMULTIREADEXCLUSIVEWRITESYNCHRONIZER_$_IREADWRITESYNC_$_5_$_SYSUTILS_TMULTIREADEXCLUSIVEWRITESYNCHRONIZER_$__BEGINWRITE$$BOOLEAN
0 2
cfn=(286) SYSUTILS_TMULTIREADEXCLUSIVEWRITESYNCHRONIZER_$__BEGINWRITE$$BOOLEAN
calls=1 0
0 86
fn=(294) SYSTEM_INTERLOCKEDEXCHANGEADD$LONGINT$LONGINT$$LONGINT
0 8
fn=(302) SYSTEM_LEAVECRITICALSECTION$TRTLCRITICALSECTION
0 12
cfn=(170) SYSTEM_NOCRITICALSECTION$formal
calls=3 0
0 24
0 6
fn=(304)
0 83
cfn=(310) CLASSES_TLIST_$__DESTROY
calls=1 0
0 662
cfn=(320) SYSTEM_TOBJECT_$__DESTROY
calls=3 0
0 620
cfn=(328) CLASSES_TSTRINGLIST_$__DESTROY
calls=1 0
0 381
cfn=(306) CLASSES_TTHREADLIST_$__DESTROY
calls=2 0
0 1430
0 22
fn=(305)
0 45
cfn=(316) CLASSES_TFPLIST_$__DESTROY
calls=3 0
0 709
cfn=(310)
calls=2 0
0 796
0 10
fn=(316)
0 36
cfn=(308) SYSTEM_TOBJECT_$__BEFOREDESTRUCTION
calls=3 0
0 3
0 6
cfn=(318) CLASSES_TFPLIST_$__CLEAR
calls=3 0
0 181
0 9
cfn=(320)
calls=3 0
0 51
0 24
cfn=(322) SYSTEM_TOBJECT_$__FREEINSTANCE
calls=3 0
0 387
0 12
fn=(322)
0 65
cfn=(324) SYSTEM_TOBJECT_$__CLEANUPINSTANCE
calls=13 0
0 691
0 26
cfn=(266) SYSTEM_FREEMEM$POINTER$$QWORD
calls=13 0
0 1124
0 39
fn=(354) SYSTEM_NORTLEVENTDESTROY$PRTLEVENT
0 24
fn=(402) OBJPAS_FINALIZERESOURCETABLES
0 1220
cfn=(152)
calls=597 0
0 8353
0 4797
fn=(18) SYSTEM_FPGETRLIMIT$LONGINT$PRLIMIT$$LONGINT
0 5
cfn=(20) SYSTEM_FPSYSCALL$INT64$INT64$INT64$$INT64
calls=1 0
0 11
0 2
fn=(20)
0 66
fn=(34)
0 10
cfn=(36) SYSTEM_OPENSTDIO$TEXT$LONGINT$LONGINT
calls=1 0
0 239
0 9
cfn=(36)
calls=1 0
0 277
0 9
cfn=(36)
calls=1 0
0 277
0 9
cfn=(36)
calls=1 0
0 277
0 9
cfn=(36)
calls=1 0
0 277
0 2
fn=(44) SYSTEM_FPIOCTL$LONGINT$LONGINT$POINTER$$LONGINT
0 24
cfn=(46)
calls=4 0
0 48
0 8
fn=(56) SYSTEM_SETTHREADMANAGER$TTHREADMANAGER$$BOOLEAN
0 60
fn=(66) UNIX_GETTIMEZONEFILE$$SHORTSTRING
0 9
cfn=(68)
calls=1 0
0 191
0 8
cfn=(76) BASEUNIX_FPREAD$LONGINT$formal$QWORD$$INT64
calls=1 0
0 24
0 6
cfn=(80) SYSTEM_POS$CHAR$SHORTSTRING$$INT64
calls=1 0
0 91
0 9
cfn=(82) SYSTEM_FPCLOSE$LONGINT$$LONGINT
calls=1 0
0 17
0 4
cfn=(86) fpc_shortstr_to_shortstr
calls=1 0
0 68
0 6
fn=(108)
0 62585
cfn=(110) SYSTEM_TRY_FINISH_WAITFIXEDLIST$PFREELISTS$$BOOLEAN
calls=5 0
0 70
0 30
cfn=(112) SYSTEM_ALLOC_OSCHUNK$PFREELISTS$QWORD$QWORD$$POINTER
calls=5 0
0 42841
0 66728
fn=(116) SYSTEM_FPMMAP$POINTER$QWORD$LONGINT$LONGINT$LONGINT$INT64$$POINTER
0 75
cfn=(118) SYSTEM_FPSYSCALL$INT64$INT64$INT64$INT64$INT64$INT64$INT64$$INT64
calls=5 0
0 75
0 10
fn=(136) SYSUTILS_EXCEPTION_$__CREATE$ANSISTRING$$EXCEPTION
0 28
cfn=(138) SYSTEM_TOBJECT_$__NEWINSTANCE$$TOBJECT
calls=2 0
0 322
0 16
cfn=(142)
calls=2 0
0 48
0 4
cfn=(144)
calls=2 0
0 24
0 14
cfn=(142)
calls=2 0
0 48
0 4
cfn=(144)
calls=2 0
0 24
0 12
cfn=(146) SYSTEM_TOBJECT_$__CREATE$$TOBJECT
calls=2 0
0 180
0 4
cfn=(150)
calls=2 0
0 22
0 4
cfn=(152)
calls=2 0
0 18
0 6
cfn=(148)
calls=2 0
0 34
0 26
cfn=(154)
calls=2 0
0 2
0 2
cfn=(148)
calls=2 0
0 34
0 16
fn=(142)
0 24816
fn=(158)
0 5
cfn=(16)
calls=1 0
0 29
0 62
fn=(180) CLASSES_TTHREADLIST_$__CREATE$$TTHREADLIST
0 26
cfn=(138)
calls=2 0
0 6989
0 16
cfn=(142)
calls=2 0
0 48
0 4
cfn=(144)
calls=2 0
0 24
0 14
cfn=(142)
calls=2 0
0 48
0 4
cfn=(144)
calls=2 0
0 24
0 12
cfn=(146)
calls=2 0
0 180
0 6
cfn=(168)
calls=2 0
0 28
0 6
cfn=(182) CLASSES_TLIST_$__CREATE$$TLIST
calls=2 0
0 1342
0 4
cfn=(148)
calls=2 0
0 34
0 26
cfn=(154)
calls=2 0
0 2
0 2
cfn=(148)
calls=2 0
0 34
0 16
fn=(200)
0 3
cfn=(202) SYSTEM_DECLOCKED$LONGINT$$BOOLEAN
calls=1 0
0 10
0 2
fn=(204) fpc_intf_incr_ref
0 8
cfn=(206) WRPR_SYSUTILS_TMULTIREADEXCLUSIVEWRITESYNCHRONIZER_$_IREADWRITESYNC_$_1_$_SYSTEM_TINTERFACEDOBJECT_$___ADDREF$$LONGINT
calls=1 0
0 17
0 2
fn=(212) fpc_intf_decr_ref
0 24
cfn=(342) WRPR_SYSUTILS_TMULTIREADEXCLUSIVEWRITESYNCHRONIZER_$_IREADWRITESYNC_$_2_$_SYSTEM_TINTERFACEDOBJECT_$___RELEASE$$LONGINT
calls=1 0
0 255
0 13
fn=(216) CLASSES_TLIST_$__GETCOUNT$$LONGINT
0 15
fn=(232) SYSTEM_SGENRAND_MT19937$LONGINT
0 11844
fn=(258)
0 26050
cfn=(260) SYSTEM_DO_WRITE$LONGINT$POINTER$LONGINT$$LONGINT
calls=2002 0
0 134134
0 16024
fn=(268) SYSTEM_SYSFREEMEM$POINTER$$QWORD
0 60616
cfn=(270) SYSTEM_SYSFREEMEM_FIXED$PFREELISTS$PMEMCHUNK_FIXED$$QWORD
calls=2020 0
0 98406
0 16167
fn=(298) CLASSES_TTHREADLIST_$__LOCKLIST$$TLIST
0 15
cfn=(288) SYSTEM_ENTERCRITICALSECTION$TRTLCRITICALSECTION
calls=3 0
0 42
0 12
fn=(328)
0 15
cfn=(308)
calls=1 0
0 1
0 25
cfn=(330) CLASSES_TSTRINGLIST_$__SETCAPACITY$LONGINT
calls=1 0
0 20
0 3
cfn=(332) CLASSES_TSTRINGS_$__DESTROY
calls=1 0
0 57
0 9
cfn=(322)
calls=1 0
0 244
0 7
fn=(332)
0 11
cfn=(334) CLASSES_TPERSISTENT_$__DESTROY
calls=1 0
0 37
0 9
fn=(340) CLASSES_REMOVEFIXUPREFERENCES$TCOMPONENT$ANSISTRING
0 9
fn=(366) CLASSES_TFPLIST_$__DELETE$LONGINT
0 28
cfn=(40) SYSTEM_MOVE$formal$formal$INT64
calls=1 0
0 12
0 8
fn=(378)
0 7
cfn=(304)
calls=1 0
0 244
0 6
cfn=(304)
calls=1 0
0 244
0 2
fn=(380) SYSUTILS_EHEAPMEMORYERROR_$__FREEINSTANCE
0 8
cfn=(322)
calls=2 0
0 404
0 4
fn=(390) UNIX_DONELOCALTIME
0 7
cfn=(266)
calls=1 0
0 116
0 6
cfn=(266)
calls=1 0
0 116
0 6
cfn=(266)
calls=1 0
0 116
0 6
cfn=(266)
calls=1 0
0 17562
0 11
fn=(398)
0 25
cfn=(20)
calls=5 0
0 55
0 10
fn=(406) SYSTEM_FLUSH$TEXT
0 72
cfn=(258)
calls=4 0
0 32
0 12
fn=(0) 0x0000000000400170
0 14
cfi=(2)
cfn=(2)
calls=1 89
0 2189157
fn=(36)
0 50
cfn=(38) SYSTEM_ASSIGN$TEXT$SHORTSTRING
calls=5 0
0 1050
0 86
cfn=(42) SYSTEM_DO_ISDEVICE$LONGINT$$BOOLEAN
calls=4 0
0 116
0 45
fn=(60)
0 43
fn=(64) UNIX_INITLOCALTIME
0 3
cfn=(66)
calls=1 0
0 433
0 2
cfn=(88) UNIX_READTIMEZONEFILE$SHORTSTRING
calls=1 0
0 45986
0 2
cfn=(124) SYSTEM_FPTIME$PTIME_T$$INT64
calls=1 0
0 16
0 2
cfn=(126)
calls=1 0
0 699
0 2
fn=(88)
0 9
cfn=(70)
calls=1 0
0 75
0 8
cfn=(90) BASEUNIX_FPGETENV$SHORTSTRING$$PCHAR
calls=1 0
0 1809
0 4
cfn=(94) fpc_pchar_to_shortstr
calls=1 0
0 70
0 4
cfn=(86)
calls=1 0
0 37
0 7
cfn=(86)
calls=1 0
0 61
0 9
cfn=(72)
calls=1 0
0 62
0 5
cfn=(72)
calls=1 0
0 164
0 3
cfn=(68)
calls=1 0
0 166
0 11
cfn=(96) UNIX_READTIMEZONEFILE$SHORTSTRING_READBUF$formal$SMALLINT$$SMALLINT
calls=1 0
0 156
0 7
cfn=(100) UNIX_READTIMEZONEFILE$SHORTSTRING_DECODE$LONGINT
calls=1 0
0 28
0 3
cfn=(100)
calls=1 0
0 28
0 3
cfn=(100)
calls=1 0
0 28
0 3
cfn=(100)
calls=1 0
0 28
0 3
cfn=(100)
calls=1 0
0 28
0 3
cfn=(100)
calls=1 0
0 28
0 12
cfn=(102) SYSTEM_REALLOCMEM$POINTER$QWORD$$POINTER
calls=1 0
0 1803
0 4
cfn=(102)
calls=1 0
0 5169
0 5
cfn=(102)
calls=1 0
0 10033
0 3
cfn=(102)
calls=1 0
0 19742
0 5
cfn=(102)
calls=1 0
0 24
0 8
cfn=(96)
calls=1 0
0 213
0 6
cfn=(96)
calls=1 0
0 125
0 16
cfn=(100)
calls=1 0
0 29
0 792
cfn=(100)
calls=99 0
0 2773
0 216
cfn=(96)
calls=1 0
0 80
0 45
cfn=(96)
calls=5 0
0 400
0 48
cfn=(96)
calls=6 0
0 390
0 48
cfn=(96)
calls=6 0
0 390
0 42
cfn=(100)
calls=6 0
0 168
0 78
cfn=(96)
calls=1 0
0 89
0 16
cfn=(122) UNIX_READTIMEZONEFILE$SHORTSTRING_READBUFBYTE$$BYTE
calls=1 0
0 15
0 15
cfn=(122)
calls=5 0
0 75
0 70
cfn=(122)
calls=1 0
0 15
0 15
cfn=(122)
calls=5 0
0 75
0 62
cfn=(82)
calls=1 0
0 17
0 5
fn=(104) SYSTEM_SYSREALLOCMEM$POINTER$QWORD$$POINTER
0 73
cfn=(268)
calls=1 0
0 78
0 37
cfn=(106)
calls=5 0
0 36716
0 52
fn=(164)
0 2
cfn=(166) CLASSES_COMMONINIT
calls=1 0
0 11123
0 2
fn=(186)
0 2
cfn=(138)
calls=1 0
0 244
0 6
fn=(210)
0 20
fn=(214) CLASSES_REGISTERINITCOMPONENTHANDLER$TCOMPONENTCLASS$TINITCOMPONENTHANDLER
0 12
cfn=(182)
calls=1 0
0 671
0 5
cfn=(146)
calls=1 0
0 256
0 11
cfn=(142)
calls=1 0
0 24
0 2
cfn=(144)
calls=1 0
0 12
0 8
cfn=(216)
calls=1 0
0 3
0 5
cfn=(216)
calls=1 0
0 3
0 7
cfn=(218) CLASSES_TLIST_$__INSERT$LONGINT$POINTER
calls=1 0
0 224
0 1
cfn=(148)
calls=1 0
0 17
0 5
fn=(218)
0 8
cfn=(220) CLASSES_TFPLIST_$__INSERT$LONGINT$POINTER
calls=1 0
0 203
0 8
cfn=(226)
calls=1 0
0 1
0 4
fn=(242)
0 9009
cfn=(244)
calls=1001 0
0 135137
0 8008
cfn=(40)
calls=1001 0
0 35419
0 4004
fn=(246) SYSTEM_INCLOCKED$INT64
0 8008
fn=(324)
0 311
cfn=(336)
calls=3 0
0 112
0 268
fn=(326) SYSTEM_DONECRITICALSECTION$TRTLCRITICALSECTION
0 20
cfn=(170)
calls=5 0
0 40
0 10
fn=(336)
0 192
cfn=(152)
calls=2 0
0 28
0 12
cfn=(370) SYSTEM_ARRAYRTTI$POINTER$POINTER$TRTTIPROC
calls=2 0
0 400
0 6
cfn=(382)
calls=1 0
0 2227
0 3
cfn=(212)
calls=1 0
0 8
0 8
cfn=(386) fpc_dynarray_decr_ref
calls=2 0
0 32
0 36
fn=(337)
0 822
cfn=(152)
calls=53 0
0 742
0 122
cfn=(370)
calls=4 0
0 1746
0 232
fn=(362) CLASSES_TFPLIST_$__GET$LONGINT$$POINTER
0 38
fn=(410) SYSTEM_SYSTEM_EXIT
0 4
fn=(24) SYSTEM_INSTALLDEFAULTSIGNALHANDLER$LONGINT$SIGACTIONREC
0 36
cfn=(16)
calls=4 0
0 164
0 28
cfn=(26) SYSTEM_FPSIGACTION$LONGINT$PSIGACTIONREC$PSIGACTIONREC$$LONGINT
calls=4 0
0 136
0 16
fn=(28) SYSTEM_FPSYSCALL$INT64$INT64$INT64$INT64$INT64$$INT64
0 52
fn=(48)
0 8
cfn=(50) SYSTEM_FPREADLINK$PCHAR$PCHAR$QWORD$$LONGINT
calls=1 0
0 20
0 11
fn=(100)
0 3138
fn=(112)
0 245
cfn=(114) SYSTEM_SYSOSALLOC$QWORD$$POINTER
calls=5 0
0 320
0 42276
fn=(124)
0 4
cfn=(84) SYSTEM_FPSYSCALL$INT64$INT64$$INT64
calls=1 0
0 10
0 2
fn=(152)
0 55295
cfn=(248) SYSTEM_DECLOCKED$INT64$$BOOLEAN
calls=3003 0
0 30030
0 18018
cfn=(266)
calls=2002 0
0 168168
0 19003
fn=(222) CLASSES_TFPLIST_$__EXPAND$$TFPLIST
0 22
cfn=(224) CLASSES_TFPLIST_$__SETCAPACITY$LONGINT
calls=1 0
0 142
0 6
fn=(224)
0 36
cfn=(102)
calls=2 0
0 227
0 10
fn=(240)
0 258863
fn=(260)
0 26026
cfn=(262) SYSTEM_FPWRITE$LONGINT$PCHAR$QWORD$$INT64
calls=2002 0
0 40040
0 4004
cfn=(264) SYSTEM_GETERRNO$$LONGINT
calls=2002 0
0 20020
0 44044
fn=(262)
0 12012
cfn=(46)
calls=2002 0
0 24024
0 4004
fn=(264)
0 20020
fn=(278) SYSTEM_FINALIZEUNITS
0 91
cfn=(400) OBJPAS_finalize
calls=1 0
0 14374
cfn=(388) UNIX_finalize
calls=1 0
0 17950
cfn=(374)
calls=1 0
0 3184
cfn=(372) TYPINFO_finalize_implicit
calls=1 0
0 167
cfn=(280) CLASSES_finalize
calls=1 0
0 3715
0 30
fn=(280)
0 2
cfn=(282) CLASSES_COMMONCLEANUP
calls=1 0
0 3378
0 5
cfn=(212)
calls=1 0
0 8
0 5
cfn=(336)
calls=1 0
0 315
0 2
fn=(286)
0 5
cfn=(288)
calls=1 0
0 14
0 2
cfn=(190)
calls=1 0
0 14
0 2
cfn=(290) SYSTEM_BASICEVENTRESETEVENT$POINTER
calls=1 0
0 14
0 2
cfn=(210)
calls=1 0
0 10
0 4
cfn=(294)
calls=1 0
0 8
0 4
cfn=(296) SYSTEM_READBARRIER
calls=1 0
0 2
0 5
fn=(290)
0 4
cfn=(292) SYSTEM_NOBASICEVENTRESETEVENT$POINTER
calls=1 0
0 8
0 2
fn=(306)
0 24
cfn=(308)
calls=2 0
0 2
0 4
cfn=(298)
calls=2 0
0 46
0 8
cfn=(142)
calls=2 0
0 48
0 4
cfn=(144)
calls=2 0
0 24
0 12
cfn=(305)
calls=2 0
0 818
0 6
cfn=(320)
calls=2 0
0 34
0 2
cfn=(148)
calls=2 0
0 34
0 4
cfn=(300) CLASSES_TTHREADLIST_$__UNLOCKLIST
calls=2 0
0 38
0 6
cfn=(326)
calls=2 0
0 28
0 26
cfn=(322)
calls=2 0
0 258
0 4
fn=(310)
0 36
cfn=(308)
calls=3 0
0 3
0 21
cfn=(312) CLASSES_TLIST_$__CLEAR
calls=3 0
0 146
0 6
cfn=(314)
calls=3 0
0 763
0 9
cfn=(320)
calls=3 0
0 51
0 24
cfn=(322)
calls=3 0
0 387
0 12
fn=(318)
0 18
cfn=(368) CLASSES_TFPLIST_$__SETCOUNT$LONGINT
calls=1 0
0 19
0 3
cfn=(224)
calls=1 0
0 131
0 10
fn=(320)
0 108
cfn=(308)
calls=3 0
0 3
0 69
cfn=(380)
calls=2 0
0 416
cfn=(322)
calls=1 0
0 129
0 48
fn=(348) SYSUTILS_TMULTIREADEXCLUSIVEWRITESYNCHRONIZER_$__DESTROY
0 12
cfn=(350)
calls=1 0
0 6
0 3
cfn=(194)
calls=1 0
0 7
0 2
cfn=(326)
calls=1 0
0 14
0 2
cfn=(352) SYSTEM_RTLEVENTDESTROY$PRTLEVENT
calls=1 0
0 14
0 2
cfn=(356) SYSTEM_BASICEVENTDESTROY$POINTER
calls=1 0
0 14
0 8
cfn=(322)
calls=1 0
0 136
0 4
fn=(356)
0 4
cfn=(358) SYSTEM_NOBASICEVENTDESTROY$POINTER
calls=1 0
0 8
0 2
fn=(360) CLASSES_TLIST_$__GET$LONGINT$$POINTER
0 3
cfn=(362)
calls=1 0
0 19
0 2
fn=(368)
0 19
fn=(386)
0 32
fn=(408) SYSTEM_FINALIZEHEAP
0 48
cfn=(392)
calls=4 0
0 20402
0 29
fn=(22)
0 4
cfn=(24)
calls=1 0
0 95
0 3
cfn=(24)
calls=1 0
0 95
0 3
cfn=(24)
calls=1 0
0 95
0 3
cfn=(24)
calls=1 0
0 95
0 2
fn=(50)
0 6
cfn=(46)
calls=1 0
0 12
0 2
fn=(52)
0 9
cfn=(54) SYSTEM_SETNOTHREADMANAGER
calls=1 0
0 177
0 2
fn=(54)
0 115
cfn=(56)
calls=1 0
0 60
0 2
fn=(58)
0 1
fn=(76)
0 4
cfn=(78)
calls=2 0
0 40
0 4
fn=(90)
0 6
cfn=(70)
calls=1 0
0 73
0 5
cfn=(72)
calls=1 0
0 62
0 2
cfn=(92) BASEUNIX_FPGETENV$PCHAR$$PCHAR
calls=1 0
0 1659
0 2
fn=(102)
0 28
cfn=(104)
calls=7 0
0 36956
0 14
fn=(134) SYSUTILS_INITEXCEPTIONS
0 12
cfn=(136)
calls=1 0
0 446
0 10
cfn=(136)
calls=1 0
0 446
0 15
fn=(160)
0 1385
cfn=(40)
calls=1 0
0 48
0 1383
cfn=(40)
calls=1 0
0 48
0 2
fn=(168)
0 20
cfn=(170)
calls=5 0
0 40
0 10
fn=(206)
0 2
cfn=(208)
calls=1 0
0 15
fn=(220)
0 18
cfn=(222)
calls=1 0
0 170
0 15
fn=(274)
0 2
cfn=(276) SYSTEM_INTERNALEXIT
calls=1 0
0 60224
0 1
cfn=(410)
calls=1 0
0 4
fn=(288)
0 16
cfn=(170)
calls=4 0
0 32
0 8
fn=(296)
0 2
fn=(312)
0 20
cfn=(216)
calls=1 0
0 3
0 5
cfn=(364) CLASSES_TLIST_$__DELETE$LONGINT
calls=1 0
0 93
0 25
fn=(330)
0 20
fn=(338) SYSTEM_APPEND_TO_OSLIST$POSCHUNK
0 88
cfn=(392)
calls=1 0
0 17451
0 37
fn=(344) SYSTEM_TINTERFACEDOBJECT_$___RELEASE$$LONGINT
0 6
cfn=(346) SYSTEM_INTERLOCKEDDECREMENT$LONGINT$$LONGINT
calls=1 0
0 10
0 8
cfn=(348)
calls=1 0
0 224
0 5
fn=(404) SYSTEM_SYSFLUSHSTDIO
0 17
cfn=(406)
calls=1 0
0 29
0 16
cfn=(406)
calls=1 0
0 29
0 16
cfn=(406)
calls=1 0
0 29
0 16
cfn=(406)
calls=1 0
0 29
0 2
fn=(8)
0 44
fn=(38)
0 45
cfn=(16)
calls=5 0
0 830
0 85
cfn=(40)
calls=5 0
0 70
0 20
fn=(40)
0 197896
fn=(42)
0 16
cfn=(44)
calls=4 0
0 80
0 20
fn=(70)
0 72
cfn=(40)
calls=4 0
0 189
0 36
fn=(82)
0 10
cfn=(84)
calls=2 0
0 20
0 4
fn=(92)
0 1659
fn=(98) UNIX_READTIMEZONEFILE$SHORTSTRING_READFILEBUF
0 12
cfn=(76)
calls=1 0
0 24
0 2
fn=(128)
0 19
cfn=(130) UNIX_FIND_TRANSITION$LONGINT$$PTTINFO
calls=1 0
0 515
0 159
fn=(138)
0 91
cfn=(140) SYSTEM_GETMEM$POINTER$QWORD
calls=13 0
0 7965
0 91
cfn=(16)
calls=13 0
0 473
0 68
cfn=(188)
calls=1 0
0 63
0 65
fn=(140)
0 14105
cfn=(106)
calls=2015 0
0 181998
0 8060
fn=(148)
0 17578
fn=(182)
0 39
cfn=(138)
calls=3 0
0 459
0 24
cfn=(142)
calls=3 0
0 72
0 6
cfn=(144)
calls=3 0
0 36
0 21
cfn=(142)
calls=3 0
0 72
0 6
cfn=(144)
calls=3 0
0 36
0 18
cfn=(146)
calls=3 0
0 270
0 9
cfn=(146)
calls=3 0
0 768
0 6
cfn=(148)
calls=3 0
0 51
0 39
cfn=(154)
calls=3 0
0 3
0 3
cfn=(148)
calls=3 0
0 51
0 24
fn=(244)
0 34034
cfn=(140)
calls=2002 0
0 196198
0 40040
fn=(248)
0 30030
fn=(250)
0 86086
cfn=(252)
calls=2002 0
0 187030
0 12012
fn=(282)
0 11
cfn=(284)
calls=1 0
0 88
0 3
cfn=(298)
calls=1 0
0 23
0 5
cfn=(142)
calls=1 0
0 24
0 2
cfn=(144)
calls=1 0
0 12
0 5
cfn=(216)
calls=1 0
0 3
0 7
cfn=(148)
calls=1 0
0 17
0 3
cfn=(300)
calls=1 0
0 19
0 6
cfn=(304)
calls=1 0
0 726
0 3
cfn=(304)
calls=1 0
0 726
0 3
cfn=(304)
calls=1 0
0 392
0 3
cfn=(340)
calls=1 0
0 9
0 2
cfn=(326)
calls=1 0
0 14
0 8
cfn=(304)
calls=1 0
0 7
0 3
cfn=(304)
calls=1 0
0 7
0 2
cfn=(314)
calls=1 0
0 14
0 2
cfn=(212)
calls=1 0
0 268
0 9
cfn=(216)
calls=1 0
0 3
0 12
cfn=(360)
calls=1 0
0 24
0 2
cfn=(304)
calls=1 0
0 165
0 5
cfn=(304)
calls=1 0
0 673
0 5
cfn=(304)
calls=1 0
0 7
0 4
cfn=(326)
calls=1 0
0 14
0 3
cfn=(352)
calls=1 0
0 14
0 3
cfn=(352)
calls=1 0
0 14
0 4
fn=(292)
0 8
fn=(334)
0 11
cfn=(320)
calls=1 0
0 17
0 9
fn=(358)
0 8
fn=(364)
0 9
cfn=(362)
calls=1 0
0 19
0 4
cfn=(366)
calls=1 0
0 48
0 7
cfn=(226)
calls=1 0
0 1
0 5
fn=(372)
0 4
cfn=(336)
calls=1 0
0 143
0 2
cfn=(152)
calls=1 0
0 14
0 4
fn=(376)
0 192
fn=(14)
0 9
cfn=(16)
calls=1 0
0 29
0 6
cfn=(18)
calls=1 0
0 18
0 12
fn=(72)
0 138
cfn=(40)
calls=4 0
0 84
0 15
cfn=(40)
calls=1 0
0 42
0 4
cfn=(40)
calls=1 0
0 73
0 56
fn=(84)
0 30
fn=(86)
0 52
cfn=(40)
calls=4 0
0 133
0 20
fn=(96)
0 651
cfn=(40)
calls=22 0
0 774
0 225
cfn=(98)
calls=1 0
0 38
0 155
fn=(110)
0 70
fn=(118)
0 75
fn=(146)
0 135
cfn=(138)
calls=5 0
0 802
0 89
cfn=(142)
calls=12 0
0 288
0 24
cfn=(144)
calls=12 0
0 144
0 128
cfn=(154)
calls=5 0
0 5
0 12
cfn=(148)
calls=12 0
0 204
0 96
fn=(166)
0 3
cfn=(168)
calls=1 0
0 14
0 1
cfn=(172)
calls=1 0
0 15
0 3
cfn=(172)
calls=1 0
0 15
0 5
cfn=(176) SYSTEM_GETCURRENTTHREADID$$QWORD
calls=1 0
0 21
0 4
cfn=(168)
calls=1 0
0 14
0 7
cfn=(180)
calls=1 0
0 7777
0 5
cfn=(180)
calls=1 0
0 1112
0 5
cfn=(146)
calls=1 0
0 273
0 6
cfn=(184)
calls=1 0
0 526
0 6
cfn=(204)
calls=1 0
0 27
0 2
cfn=(212)
calls=1 0
0 8
0 6
cfn=(214)
calls=1 0
0 1266
0 2
fn=(170)
0 136
fn=(172)
0 12
cfn=(174)
calls=3 0
0 27
0 6
fn=(176)
0 4
cfn=(178)
calls=1 0
0 15
0 2
fn=(202)
0 10
fn=(230)
0 10021
cfn=(232)
calls=1 0
0 11844
0 66698
fn=(234)
0 18018
fn=(252)
0 104104
cfn=(40)
calls=4004 0
0 161004
0 32032
fn=(266)
0 8076
cfn=(268)
calls=2019 0
0 175088
0 4038
fn=(270)
0 68705
cfn=(338)
calls=5 0
0 17576
0 12125
fn=(342)
0 2
cfn=(344)
calls=1 0
0 253
fn=(346)
0 10
fn=(370)
0 168
cfn=(337)
calls=6 0
0 204
0 280
cfn=(337)
calls=40 0
0 1360
0 134
fn=(394)
0 37591
fn=(400)
0 2
cfn=(402)
calls=1 0
0 14370
0 2
fn=(6)
0 5
cfn=(8)
calls=1 0
0 22
0 5
cfn=(10)
calls=1 0
0 20
0 2
fn=(10)
0 40
fn=(16)
0 1685
fn=(26)
0 76
cfn=(28)
calls=4 0
0 52
0 8
fn=(32)
0 17
fn=(62)
0 2
cfn=(64)
calls=1 0
0 47145
0 2
fn=(80)
0 91
fn=(94)
0 25
cfn=(86)
calls=1 0
0 39
0 6
fn=(114)
0 45
cfn=(116)
calls=5 0
0 160
0 30
cfn=(120) SYSTEM_SETERRNO$LONGINT
calls=5 0
0 65
0 20
fn=(120)
0 65
fn=(122)
0 180
fn=(130)
0 515
fn=(132)
0 3
cfn=(134)
calls=1 0
0 929
0 1
cfn=(156)
calls=1 0
0 2967
0 3
cfn=(152)
calls=1 0
0 9
0 8
fn=(150)
0 11029
cfn=(246)
calls=1001 0
0 8008
0 2006
fn=(162)
0 3
fn=(190)
0 8
cfn=(192)
calls=2 0
0 16
0 4
fn=(276)
0 9
cfn=(278)
calls=1 0
0 39511
0 11
cfn=(404)
calls=1 0
0 183
0 3
cfn=(268)
calls=1 0
0 23
0 1
cfn=(408)
calls=1 0
0 20479
0 4
fn=(300)
0 9
cfn=(302)
calls=3 0
0 42
0 6
fn=(308)
0 12
fn=(352)
0 12
cfn=(354)
calls=3 0
0 24
0 6
fn=(384)
0 9
fn=(388)
0 2
cfn=(390)
calls=1 0
0 17946
0 2
totals: 2189171
-------------- next part --------------
program IntToStr;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes, SysUtils
{ you can add units after this };
function MyIntToStr (n: Integer): AnsiString;
const
Pow10: array [0..9] of Integer=
(1, 10, 100, 1000, 10000, 100000, 1000000,
10000000, 100000000, 1000000000);
function GetLength (n: Integer): Integer;
var
Top, Bot, Mid: Integer;
begin
Bot:= 0; Top:= 9;
if Pow10 [Top]<= n then
Exit (Top+ 1);
if n<= Pow10 [Bot] then
Exit (Bot+ 1);
while Bot<= Top do
begin
Mid:= (Top+ Bot) shr 1;
if n< Pow10 [Mid] then
Top:= Mid- 1
else if Pow10 [Mid]<= n then
Bot:= Mid+ 1
else
Exit (Mid+ 1);
end;
Result:= Bot;
end;
var
RightPtr: PChar;
Len: Integer;
IsNegative: Boolean;
begin
if n< 0 then
begin
n:= -n;
IsNegative:= True;
end
else
IsNegative:= False;
if n= 0 then
Exit ('0');
Len:= 0;
if Pow10 [High (Pow10)]< n then
Len:= High (Pow10)+ 1
else
while Pow10 [Len]<= n do
Inc (Len);
SetLength (Result, Len);
RightPtr:= @(Result [1])+ Len- 1;
while n<> 0 do
begin
RightPtr^:= char (48+ (n mod 10));
n:= n div 10;
Dec (RightPtr);
end;
end;
var
i: Integer;
n: Integer;
begin
for i:= 0 to 1000 do
begin
n:= i;Random (MaxInt);
WriteLn (SysUtils.IntToStr (n), '.');
WriteLn (MyIntToStr (n), '.');
end;
end.
More information about the fpc-devel
mailing list