跪求性能最佳的读/分析文件代码 ( 积分: 200 )

  • 主题发起人 主题发起人 x-dsl
  • 开始时间 开始时间
X

x-dsl

Unregistered / Unconfirmed
GUEST, unregistred user!
1)文件教大,有没有办法先把文件放到内存然后再读(文本文件,面对行的)?<br>2)每行的内容如下:123.333 323.111;由于中间有个空格,而且读出来的时候是字符串,那位高手能提供最优的算法,把这两项赋值到(var a,b :Double)?因为数据量巨大,所以这个算法很重要,可以的话可以用汇编。<br>再次感谢
 
1)文件教大,有没有办法先把文件放到内存然后再读(文本文件,面对行的)?<br>2)每行的内容如下:123.333 323.111;由于中间有个空格,而且读出来的时候是字符串,那位高手能提供最优的算法,把这两项赋值到(var a,b :Double)?因为数据量巨大,所以这个算法很重要,可以的话可以用汇编。<br>再次感谢
 
1、使用内存 mapfile,在 delphi 5 开发人员指南中有实例代码<br>2、这是 HyperString 中使用的函数:<br><br>function ChrToDbl(const Source:AnsiString):Double;<br><br> &nbsp;{Convert any 8 char. string into a Double floating point value. See<br> &nbsp; IntToChr for discussion. As always with floating point, the<br> &nbsp; representation is only approximate.}<br><br> &nbsp;asm<br> &nbsp; &nbsp;Push &nbsp;EDI<br> &nbsp; &nbsp;Push &nbsp;ESI<br><br> &nbsp; &nbsp;Mov &nbsp; ESI,EAX &nbsp; &nbsp; &nbsp; &nbsp; //Move address to EDX<br> &nbsp; &nbsp;Xor &nbsp; EDX,EDX<br> &nbsp; &nbsp;Xor &nbsp; EAX,EAX &nbsp; &nbsp; &nbsp; &nbsp; //Default return<br> &nbsp; &nbsp;Or &nbsp; &nbsp;ESI,ESI<br> &nbsp; &nbsp;Jz &nbsp; &nbsp;@Done<br> &nbsp; &nbsp;Mov &nbsp; ECX,[ESI-4] &nbsp; &nbsp; //String Length into ECX<br> &nbsp; &nbsp;Cmp &nbsp; ECX,8 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Less than 8 bytes?<br> &nbsp; &nbsp;Jb &nbsp; &nbsp;@Done &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Yes, then abort<br><br> &nbsp; &nbsp;Mov &nbsp; EDX,[ESI] &nbsp; &nbsp; &nbsp; //put 4 MSB into EDX<br> &nbsp; &nbsp;BSwap EDX<br><br> &nbsp; &nbsp;Mov &nbsp; EAX,[ESI+4] &nbsp; &nbsp; //put 4 LSB into EAX<br> &nbsp; &nbsp;BSwap EAX<br>@Done:<br> &nbsp; &nbsp;Lea &nbsp; EDI,@Result<br> &nbsp; &nbsp;Mov &nbsp; [EDI],EAX<br> &nbsp; &nbsp;Mov &nbsp; [EDI+4],EDX<br><br> &nbsp; &nbsp;Pop &nbsp; ESI<br> &nbsp; &nbsp;Pop &nbsp; EDI<br> &nbsp;end; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//and we're outta here
 
去http://delphi.freemai.com上问一下
 
多人接受答案了。
 
后退
顶部