このページはEtoJ逐語翻訳フィルタによって翻訳生成されました。

翻訳前ページへ


Language

The 解放する/自由な and Open 生産性 控訴
解放(する)d: Apache OpenOffice 4.1.16

分析 of 名簿(に載せる)/表(にあげる) class uses

要約

All code that uses OOo's 名簿(に載せる)/表(にあげる) class (ie DECLARE_LIST(foo, OString)) should be 変えるd to use std::vector or std::deque since these 機能(する)/行事s are more efficient, faster, and better understood. Little work is 要求するd for this 転換 as the functionality of 名簿(に載せる)/表(にあげる) and std::vector/std::deque is pretty much the same.

Results Spreadsheet: ListComparison.sxc

Problem

OOo uses its 内部の 名簿(に載せる)/表(にあげる) class (see 道具s/inc/名簿(に載せる)/表(にあげる).hxx) in a fair number of places. This code was written 初めは in 1991/1992 and is probably pre-基準 Template Library. Its usage is a bit arcane, and the STL 実施s of さまざまな 名簿(に載せる)/表(にあげる) variants are probably more understood and better 器具/実施するd. The 道具s 名簿(に載せる)/表(にあげる) class is 器具/実施するd using C 大型のs, as such:

DECLARE_LIST( list_class_name, list_class_type )

After this 声明, a class 指名するd "list_class_name" will 存在する, which 蓄える/店s 反対するs of type "list_class_type". The 名簿(に載せる)/表(にあげる) class has a number of 機能(する)/行事s that 成し遂げる 操作/手術s such as 除去 of elements, insertion of elements, and 独断的な retrieval of elements. However, this is a 非,不,無-基準 API (compared to the STL), and as we will see below, is not as efficient as 確かな STL classes.

Comparison of Classes

4 名簿(に載せる)/表(にあげる) classes were compared: OOo's 道具s 名簿(に載せる)/表(にあげる) class, and STLport's std::名簿(に載せる)/表(にあげる), std::vector, and std::deque. It is 公正に/かなり trivial to 変える instances of the 道具s 名簿(に載せる)/表(にあげる) class over to 同等(の) STL classes, 産する/生じるing better 業績/成果 for the 操作/手術s OOo code most uses.

実験(する)ing methodology was 公正に/かなり informal, and the results of the 速度(を上げる) 実験(する)s are not 絶対の. They should give a best-事例/患者 シナリオ of the efficiency and 速度(を上げる) of which each particular 名簿(に載せる)/表(にあげる) class 完全にするs 確かな 操作/手術s. For each class, a small 実験(する) program was run, which 実験(する)d 5 操作/手術s 30 times each, for 10, 100, 1000, and 10000 名簿(に載せる)/表(にあげる) elements. An 普通の/平均(する) was then calculated and printed to stderr. 名簿(に載せる)/表(にあげる) elements were of type 'int'.

  1. 創造 of 名簿(に載せる)/表(にあげる) with N elements
  2. Deletion of 名簿(に載せる)/表(にあげる) with N elements
  3. Sequential 除去 of all elements, from 前線 (含むing dereference of iterator)
  4. Sequential 除去 of all elements, from 支援する (含むing dereference of iterator)
  5. Sequential iteration of all elements in the 名簿(に載せる)/表(にあげる), 前線->支援する

The 実験(する) program was run 4 times, and the best 普通の/平均(する) 得点する/非難する/20 from each of the 操作/手術s from all 4 times was 記録,記録的な/記録するd as the final time. I.E.: run once (30-run 普通の/平均(する) for each of the 5 ops), enter times. Run 3 more times and enter best time from any 実験(する) for each of the 5 操作/手術s.

stl-名簿(に載せる)/表(にあげる).cxx   stl-vector.cxx   stl-deque.cxx   ooo-名簿(に載せる)/表(にあげる).cxx


Results

操作/手術 STL std::名簿(に載せる)/表(にあげる) STL std::vector STL std::deque OOo 名簿(に載せる)/表(にあげる)
Create 10e 8 9 6 8 Chart
削除する 10e 8 7 7 7
除去する 前線 10e 8
7 8
除去する 支援する 10e 8 6 7 7
Iteration 10e 7 7 7 7





Create 100e 25 12 8 24 Chart
削除する 100e 24 7 8 9
除去する 前線 100e 24
8 27
除去する 支援する 100e 24 7 8 16
Iteration 100e 7 7 7 7





Create 1000e 192 19 20 179 Chart
削除する 1000e 159 8 12 9
除去する 前線 1000e 177
15 791
除去する 支援する 1000e 180 7 14 111
Iteration 1000e 11 7 9 7





Create 10000e 1762 231 126 1068 Chart
削除する 10000e 1513 22 56 12
除去する 前線 10000e 1711
85 7975
除去する 支援する 10000e 1720 13 82 1064
Iteration 10000e 57 13 28 13

NOTE: all times are in u-seconds

分析

OOo 名簿(に載せる)/表(にあげる) class: not the best choice for some 操作/手術s. In fact, it does horribly at 除去するing items from the 前線 of the 名簿(に載せる)/表(にあげる), and not やめる so 不正に at 除去するing items from the 後部. In fact, it was 設立する that 除去する items from a 宙返り飛行 as follows (which is done やめる often in OOo) is even worse, by a factor of 10 or more:

	while(mpPageMasterInfoList->Count())
		削除する mpPageMasterInfoList->除去する(mpPageMasterInfoList->Count() - 1L);

Using the 除去する( N ) 機能(する)/行事 is much slower than using the 除去する() 機能(する)/行事. 除去する() 簡単に 除去するs the node pointed to by the 現在の 名簿(に載せる)/表(にあげる) pointer, which is 始める,決める using 前線(), 支援する(), Next(), and Prev(). Rewriting the code as such 伸び(る)s a factor of 10 速度(を上げる) 増加する, at least in this 限られた/立憲的な 実験(する) 事例/患者:
	while(mpPageMasterInfoList->Count())
	{
		mpPageMasterInfoList->Last();
		削除する mpPageMasterInfoList->除去する();
	}

In general though, the OOo 名簿(に載せる)/表(にあげる) class 成し遂げるs 貧しく compared to the STL's std::vector and std::deque.


std::名簿(に載せる)/表(にあげる): while faster than the OOo 名簿(に載せる)/表(にあげる) class, it is not as ideal as std::vector or std::deque.


std::vector: while faster than the OOo 名簿(に載せる)/表(にあげる) class and std::名簿(に載せる)/表(にあげる), it is not as ideal as std::deque because it does not support 長,率いる-除去 (ie pop_front()).


std::deque: while not always the fastest class, it is 一般に in the same class as std::vector. However, it supports 長,率いる-除去 and also 無作為の 接近 to its elements. It is therefore more versatile than std::vector and almost as 急速な/放蕩な.


推薦s

Code that uses the OOo 名簿(に載せる)/表(にあげる) class should 徐々に be 変えるd over to either std::deque or std::vector, whichever is appropriate for the 状況/情勢. This 転換 産する/生じるs the に引き続いて 利益s:

  1. Faster
  2. Better understood code and tradeoffs
  3. More 最近の code

The ASF

Copyright & License | Privacy | 接触する Us | 寄付する | Thanks

Apache, OpenOffice, OpenOffice.org and the seagull logo are 登録(する)d trademarks of The Apache ソフトウェア 創立/基礎. The ASF logo is a trademark of The Apache ソフトウェア 創立/基礎. Other 指名するs appearing on the 場所/位置 may be trademarks of their 各々の owners.