20.01.2017, 11:38 | #10 |
Участник
|
X++: class RunnableClass1 { const int StringSite = 100000; public static Int64 PlusEquals() { System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch(); stopWatch.Restart(); str s; for (int i = 1; i <= StringSite; i+=5) { s += int2Str(i); s += int2Str(i+1); s += int2Str(i+2); s += int2Str(i+3); s += int2Str(i+4); } var runtime = stopWatch.ElapsedMilliseconds; stopWatch.Stop(); return runtime; } public static Int64 Plus() { System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch(); stopWatch.Restart(); str s; for (int i = 1; i <= StringSite; i+=5) { s = s + int2Str(i) + int2Str(i+1) + int2Str(i+2) + int2Str(i+3) + int2Str(i+4); } var runtime = stopWatch.ElapsedMilliseconds; stopWatch.Stop(); return runtime; } public static Int64 ThruStrFmt() { System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch(); stopWatch.Restart(); str s; for (int i = 1; i <= StringSite; i+=5) { s = strFmt('%1%2%3%4%5%6', s, int2Str(i), int2Str(i+1), int2Str(i+2), int2Str(i+3), int2Str(i+4)); } var runtime = stopWatch.ElapsedMilliseconds; stopWatch.Stop(); return runtime; } public static Int64 ThruTextBuffer() { System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch(); stopWatch.Restart(); TextBuffer tb = new TextBuffer(); for (int i = 1; i <= StringSite; i+=5) { tb.appendText(int2Str(i)); tb.appendText(int2Str(i+1)); tb.appendText(int2Str(i+2)); tb.appendText(int2Str(i+3)); tb.appendText(int2Str(i+4)); } tb.getText(); var runtime = stopWatch.ElapsedMilliseconds; stopWatch.Stop(); return runtime; } /// <summary> /// Runs the class with the specified arguments. /// </summary> /// <param name = "_args">The specified arguments.</param> public static void main(Args _args) { Box::info("START"); info(strFmt("+= took %1 ms", RunnableClass1::PlusEquals())); info(strFmt("+ took %1 ms", RunnableClass1::Plus())); info(strFmt("strFmt took %1 ms", RunnableClass1::ThruStrFmt())); info(strFmt("TextBuffer took %1 ms", RunnableClass1::ThruTextBuffer())); Box::info("DONE"); } } |
|
|
За это сообщение автора поблагодарили: Logger (5), Товарищ ♂uatr (1). |