Experiment:The wx wrapping function

From Maths
Jump to: navigation, search

Set up

- STUB - Alec (talk) 16:38, 23 April 2017 (UTC)

  • See wxGraph project folder, and wxStaticWrappedText (my class, not a wx class)
    • during an EVT_SIZE we copy some stored wxString to the label of a wxStaticText, we then tell it to Wrap passing the usable width as a parameter, the wrap function takes the bulk of this time[Note 1]

Test string

		wxString longText("This is long, or it will be!"); //28 chars
		for(int i=0;i!=345;i++) {
			longText = longText << " longer still"; //13 char
		}

Models

  1. [ilmath]w\eq 124.1\ell^{0.9762} [/ilmath] - to [ilmath]4[/ilmath] s.f. - even for these only differ by [ilmath]\approx 1500[/ilmath] and are in the order of [ilmath]3.85[/ilmath]m [ilmath]\mu\text{S} [/ilmath]
    • Actual model: [ilmath]w\eq [/ilmath]124.085862874602[ilmath]\ell[/ilmath]0.976171971433827
    • Created from first 4 - 6 data points and compared, [ilmath]x^2[/ilmath], [ilmath]x^3[/ilmath] and [ilmath]x^4[/ilmath] models were just fitting to plot and didn't converge outside of it
  2. [ilmath]w\eq 94.85\ell^{1.020} [/ilmath] created from almost all the points except the last 1 then the last point was added to see how well it predicted
    • Actual model: [ilmath]w\eq [/ilmath]94.8492202616877[ilmath]\ell[/ilmath]1.02004775561656 - difference of about [ilmath]2.3[/ilmath]k at , they're in the order of [ilmath]4.7[/ilmath] million [ilmath]\mu\text{S} [/ilmath] anyway

Raw data

Result [ilmath]k[/ilmath][Note 2] String length Wrap time[Note 1]
1 158 17661
2 678 73366
3 353 37000
4 1328 130232
5 1653 180685
6 1003 106468
7 3278 398864
8 2290 248170
9 2758 307258
10 4513 522282

Notes

  1. 1.0 1.1 Actually the time to copy the string into the wxStaticText and the wrap time is included, but for even a short [ilmath]353[/ilmath]-length string, the copy time was [ilmath]435\ \mu\text{S} [/ilmath] per call, the bulk of that will be the cost of allocating memory not the copying cost. For reference the Wrap time for 353-length example was [ilmath]37\ \text{mS} [/ilmath] or [ilmath]\approx\ 37,000\ \mu\text{S} [/ilmath]
  2. [ilmath]\ell:\eq 28+13k[/ilmath] where [ilmath]\ell[/ilmath] is the resulting string length and [ilmath]k[/ilmath] is the number of times a string is appended to to a base string to generate it