1# -*- mode: org -*-
2# Copyright (C) 2012 International Business Machines Corporation and Others. All Rights Reserved.
3
4How Expensive Is It?
5
6* Introduction
7** The purpose of this test is to answer the question, "How expensive, relatively speaking, is ICU operation X?"
8** ICU tests are compared with general purpose CPU operations to attempt to factor out differences between systems and load conditions
9** Different ICU operations will have different levels of dependence on CPU, memory, disk, etc. So nothing can perfectly factor these conditions out.
10* Running the Test
11** Simply run "make check" in this directory, icu/source/test/perf/howExpensiveIs/
12** Try to minimize other CPU loading throughout the test
13** The test will take some time to run!
14** Test runs outside of a margin of error will be thrown out. So, this will tend to produce more accurate results.
15** After some time, the file howexpensive.xml will be created (an example is attached as Appendix I)
16** The results may be read directly or processed such as with xslt.
17** XML file contents:
18*** Element <tests>: the outermost element.
19*** Attribute 'icu':  gives the basic ICU version number.
20**** Element <test>: a particularized test.
21***** Attribute 'name': names the particular test, see howExpensiveIs.cpp for details
22***** Attribute 'standardizedTime': The SieveTest by definition has a standardized test of 1, it runs a prime number sieve as a benchmark. All other standardizedTimes are normalized against this value.
23***** Attribute 'realDuration': the actual duration, in seconds, of the test.
24***** Attribute 'marginOfError': the amount +/- error for the real duration. Gives an idea of how much variability was in the test.
25***** Attribute 'iterations': gives the total number of iterations run.
26**** Element <icuSystemParams>: This element gives the full details of the target platform, in the XML format produced by the 'icuinfo' tool.  The contents are informative only and not documented here.
27* Analysis
28** The data shows that, for example, parsing a number and opening the GB18030 converter are about the same cost. It also shows that opening a number formatter is about 60 times as expensive as formatting a number.
29** Appendix II shows a .CSV (spreadsheet) file which shows analysis of a sample run between different systems.
30** The Variation column for each Target system was calculated with the formula:  "(Control-Target)/Control" where Control and Target are the standardized times for the Control and Target systems, respectively.
31* Appendices
32** Appendix I: Sample File
33<?xml version="1.0" encoding="UTF-8" ?>
34<tests icu="49.0.2">
35<!--  Copyright (C) 2011, International Business Machines Corporation and others. All Rights Reserved.  -->
36   <test name="SieveTest" standardizedTime="1.000000" realDuration="0.022804" marginOfError="0.000073" iterations="1000000" />
37   <test name="NullTest" standardizedTime="0.000017" realDuration="0.000000" marginOfError="0.000000" iterations="1000000" />
38   <test name="NumParseTest" standardizedTime="77.869922" realDuration="1.775721" marginOfError="0.011742" iterations="1000000" />
39   <test name="Test_unum_opendefault" standardizedTime="4855.974258" realDuration="110.734117" marginOfError="0.057131" iterations="1000000" />
40   <test name="Test_ucnv_opengb18030" standardizedTime="70.488403" realDuration="1.607395" marginOfError="0.009261" iterations="1000000" />
41 <icuSystemParams type="icu4c">
42    <param name="copyright"> Copyright (C) 2011, International Business Machines Corporation and others. All Rights Reserved. </param>
43    <param name="product">icu4c</param>
44    <param name="product.full">International Components for Unicode for C/C++</param>
45    <param name="version">49.0.2</param>
46    <param name="version.unicode">6.1</param>
47    <param name="platform.number">4000</param>
48    <param name="platform.type">Other (POSIX-like)</param>
49    <param name="locale.default">en_US</param>
50    <param name="locale.default.bcp47">en-US</param>
51    <param name="converter.default">UTF-8</param>
52    <param name="icudata.name">icudt49l</param>
53    <param name="icudata.path">../../data/out/build/icudt49l</param>
54    <param name="cldr.version">21.0</param>
55    <param name="tz.version">2011n</param>
56    <param name="tz.default">America/Los_Angeles</param>
57    <param name="cpu.bits">64</param>
58    <param name="cpu.big_endian">0</param>
59    <param name="os.wchar_width">4</param>
60    <param name="os.charset_family">0</param>
61    <param name="os.host">x86_64-unknown-linux-gnu</param>
62    <param name="build.build">x86_64-unknown-linux-gnu</param>
63    <param name="build.cc">gcc</param>
64    <param name="build.cxx">g++</param>
65 </icuSystemParams>
66</tests>
67** Appendix II: Analysis.csv
68http://bugs.icu-project.org/trac/ticket/8653,"""Control"", linux i7
69Intel(R) Core(TM) i7-2720QM CPU @ 2.20GHz",MacBook 2.4ghz (Core2D),MacBook 2GhzCore2,AIX Power,MB 2.4 Variance,MB 2 variance,AIX Variance
70SieveTest (=1.0),1,1,1,1,0.00%,0.00%,0.00%
71NullTest (=0.0),0,0,0,0.08,#DIV/0!,#DIV/0!,#DIV/0!
72NumParseTest,74.10642,21.220191493,56.912133,85.423525612,71.37%,23.20%,-15.27%
73Test_unum_opendefault,4801.617798,1912.860018319,4522.900036,2580.805294162,60.16%,5.80%,46.25%
74Test_ucnv_opengb18030,65.268309,30.547740077,84.075584,51.587649619,53.20%,-28.82%,20.96%
75Test_unum_openpattern,4394.214773,1735.453339382,4472.298154,2263.471671239,60.51%,-1.78%,48.49%
76Test_ures_openroot,75.302253,23.773982586,71.248439,57.471889114,68.43%,5.38%,23.68%
77** Appendix III: Revision History
78*** Feb 2012, ICU 49, srl: First revision
79