好的,所以這個文件是410k行代碼。現在我在1.4秒內解析它,但我需要它更快。有幾個關於這個文件,雖然奇怪的事情......如何使用線程來幫助解析大文件
該文件的結構是這樣的(感謝ARM):ARM fromelf
基本上我解析這一切變成地圖,關鍵是結構的名稱,在這種情況下,由於ARM生成警告,可能會重複。這種情況下的值是後面的字段。
有沒有一種方法可以使用線程將任務分解爲多個線程,將數據添加到相同的地圖?
P.S.沒有找人爲我做這件事,我只是提供了一個文件結構是什麼樣的例子,所以你明白我不能只處理每一行,而是根據結構處理[start:finish]。
根據要求什麼,我分析的樣本:
; Structure, Table , Size 0x104 bytes, from inputfile.cpp
|Table.TableSize| EQU 0 ; int
|Table.Data| EQU 0x4 ; array[64] of MyClassHandle
; End of Structure Table
; Structure, Box2 , Size 0x8 bytes, from inputfile.cpp
|Box2.| EQU 0 ; anonymous
|Box2..| EQU 0 ; anonymous
|Box2...Min| EQU 0 ; Point2
|Box2...Min.x| EQU 0 ; short
|Box2...Min.y| EQU 0x2 ; short
|Box2...Max| EQU 0x4 ; Point2
|Box2...Max.x| EQU 0x4 ; short
|Box2...Max.y| EQU 0x6 ; short
; Warning: duplicate name (Box2..) present in (inputfile.cpp) and in (inputfile.cpp)
; please use the --qualify option
|Box2..| EQU 0 ; anonymous
|Box2...Left| EQU 0 ; unsigned short
|Box2...Top| EQU 0x2 ; unsigned short
|Box2...Right| EQU 0x4 ; unsigned short
|Box2...Bottom| EQU 0x6 ; unsigned short
; End of Structure Box2
; Structure, MyClassHandle , Size 0x4 bytes, from inputfile.cpp
|MyClassHandle.Handle| EQU 0 ; pointer to MyClass
; End of Structure MyClassHandle
; Structure, Point2 , Size 0x4 bytes, from defects.cpp
|Point2.x| EQU 0 ; short
|Point2.y| EQU 0x2 ; short
; End of Structure Point2
; Structure, __fpos_t_struct , Size 0x10 bytes, from C:\Program Files\DS-5\bin\..\include\stdio.h
|__fpos_t_struct.__pos| EQU 0 ; unsigned long long
|__fpos_t_struct.__mbstate| EQU 0x8 ; anonymous
|__fpos_t_struct.__mbstate.__state1| EQU 0x8 ; unsigned int
|__fpos_t_struct.__mbstate.__state2| EQU 0xc ; unsigned int
; End of Structure __fpos_t_struct
END
[有沒有辦法?](http://cdn.gifbay.com/2012/11/is_such_a_thing_even_possible-9397.gif) – TheBat 2014-09-23 21:48:49
必須看到你在做什麼的例子,線程化的可能性不會因爲Python股票至少有GIL解釋器與之抗衡。所以除非你有一些在隊列後端進行異步C調用,可能運氣不好。你可能能夠將它重構成一個map/reduce的問題,但沒有示例代碼..惡搞喬! – synthesizerpatel 2014-09-23 23:41:24
將文件樣本插入問題會更好。外部鏈接脆弱,有時難以訪問。 – rici 2014-09-23 23:41:46