mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
.benchmarks
git-svn-id: svn://ultimatepp.org/upp/trunk@13413 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
89e717ef0d
commit
d1c982cdbf
4 changed files with 164 additions and 0 deletions
62
benchmarks/CoLoop/CoLoop.cpp
Normal file
62
benchmarks/CoLoop/CoLoop.cpp
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
#include <Core/Core.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
Vector<String> TestData()
|
||||
{
|
||||
SeedRandom(0);
|
||||
Vector<String> data;
|
||||
for(int i = 1; i < 100; i++) {
|
||||
int n = 10 * (i + Random(i + 1));
|
||||
String h;
|
||||
for(int i = 0; i < n; i++)
|
||||
h << Random(99999) << ' ';
|
||||
data.Add(h);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
int64 SumLine(const char *s)
|
||||
{
|
||||
int64 sum = 0;
|
||||
int64 n = 0;
|
||||
while(*s) {
|
||||
if(IsDigit(*s))
|
||||
n = 10 * n + *s - '0';
|
||||
else {
|
||||
sum += n;
|
||||
n = 0;
|
||||
}
|
||||
s++;
|
||||
}
|
||||
return sum + n;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define N 1
|
||||
#else
|
||||
#define N 10000
|
||||
#endif
|
||||
|
||||
int64 gsum;
|
||||
|
||||
CONSOLE_APP_MAIN
|
||||
{
|
||||
Vector<String> data = TestData();
|
||||
|
||||
for(int i = 0; i < N; i++) {
|
||||
RTIMING("ThreadLoop *");
|
||||
CoWork co;
|
||||
int64 sum = 0;
|
||||
std::atomic<int> ii = 0;
|
||||
co.Loop([&] {
|
||||
int64 h = 0;
|
||||
for(int i = ii++; i < data.GetCount(); i = ii++)
|
||||
h += SumLine(data[i]);
|
||||
CoWork::FinLock();
|
||||
sum += h;
|
||||
});
|
||||
gsum = sum;
|
||||
DUMP(gsum);
|
||||
}
|
||||
}
|
||||
9
benchmarks/CoLoop/CoLoop.upp
Normal file
9
benchmarks/CoLoop/CoLoop.upp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
uses
|
||||
Core;
|
||||
|
||||
file
|
||||
CoLoop.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "";
|
||||
|
||||
9
benchmarks/FontMetrics/FontMetrics.upp
Normal file
9
benchmarks/FontMetrics/FontMetrics.upp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
uses
|
||||
CtrlLib;
|
||||
|
||||
file
|
||||
main.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "GUI";
|
||||
|
||||
84
benchmarks/FontMetrics/main.cpp
Normal file
84
benchmarks/FontMetrics/main.cpp
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
#include <CtrlLib/CtrlLib.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
const char *qtf =
|
||||
"[ $$0,0#00000000000000000000000000000000:Default]"
|
||||
"[*C@3+75 $$1,1#36268203433472503231438721581057:code]"
|
||||
"[*/+117 $$2,0#07143242482611002448121871408047:title]"
|
||||
"[@(128.0.255)2 $$3,0#65874547464505293575048467215454:QTF Chr]"
|
||||
"[{_}%EN-US "
|
||||
"[s0;= [*8 QTF]&]"
|
||||
"[s0; &]"
|
||||
"[s0; QTF is the native format of Ultimate`+`+ rich texts (formatted "
|
||||
"texts).&]"
|
||||
"[s0; &]"
|
||||
"[s0; It is byte oriented format. Bytes with values 2`-31 are ignored. "
|
||||
"Other are interpreted as characters or formatting commands.&]"
|
||||
"[s0; &]"
|
||||
"[s0; Letters ([@4 a]`-[@4 zA]`-[@4 Z]), numbers ([@4 0]`-[@4 9]), space (32) "
|
||||
"and characters&]"
|
||||
"[s0; &]"
|
||||
"[s0; [*@4 . , ; ! ? % ( ) / < > #]&]"
|
||||
"[s0; &]"
|
||||
"[s0; and bytes greater than 127 are guaranteed to be never used as "
|
||||
"command characters (not even in future versions of QTF). Other "
|
||||
"characters should be prefixed with escape character `` (reverse "
|
||||
"apostrophe). Group of characters can be escaped using byte 1. "
|
||||
"Example:&]"
|
||||
"[s0; &]"
|
||||
"[s1; `\"`\1a`[x`]`\1`[`* bold`]`\"&]"
|
||||
"[s0; &]"
|
||||
"[s0; Byte 0 represents the end of input sequence.&]"
|
||||
"[s0; &]"
|
||||
"[s0; Dimension units of QTF are dots `- one dot is defined as 1/600 "
|
||||
"of inch.&]"
|
||||
"[s0; &]"
|
||||
"[s0; Colors are described as either number [@(128.0.255) 0]`-[@(128.0.255) 9], "
|
||||
"with meaning&]"
|
||||
"[s0; &]"
|
||||
"[ {{1000:1000:1000:1000:1000:1000:1000:1000:1000:1000<96;>96;f4; [s0;%- [* 0]]"
|
||||
":: [s0;%- [* 1]]"
|
||||
":: [s0;%- [* 2]]"
|
||||
":: [s0;%- [* 3]]"
|
||||
":: [s0;%- [* 4]]"
|
||||
":: [s0;%- [* 5]]"
|
||||
":: [s0;%- [* 6]]"
|
||||
":: [s0;%- [* 7]]"
|
||||
":: [s0;%- [* 8]]"
|
||||
":: [s0;%- [* 9]]"
|
||||
"::l/0r/0t/0b/0@0 [s0; ]"
|
||||
"::@1 [s0; ]"
|
||||
"::@2 [s0; ]"
|
||||
"::@3 [s0; ]"
|
||||
"::@4 [s0; ]"
|
||||
"::@5 [s0; ]"
|
||||
"::@6 [s0; ]"
|
||||
"::@7 [s0; ]"
|
||||
"::@8 [s0; ]"
|
||||
"::@9 [s0; ]"
|
||||
"::l/25r/25t/15b/15@2 [s0;%- [1 Black]]"
|
||||
":: [s0; [1 LtGray]]"
|
||||
":: [s0; [1 White]]"
|
||||
":: [s0;%- [1 Red]]"
|
||||
":: [s0;%- [1 Green]]"
|
||||
":: [s0;%- [1 Blue]]"
|
||||
":: [s0;%- [1 LtRed]]"
|
||||
":: [s0;%- [1 WhiteGray]]"
|
||||
":: [s0;%- [1 LtCyan]]"
|
||||
":: [s0;%- [1 Yellow]]}}&]"
|
||||
"[s0; &]"
|
||||
;
|
||||
|
||||
int sum;
|
||||
RichText txt = ParseQTF(qtf);
|
||||
|
||||
GUI_APP_MAIN
|
||||
{
|
||||
RTIMING("Metrics");
|
||||
for(int i = 0; i < 1000; i++) {
|
||||
RichText txt2 = clone(txt);
|
||||
sum += txt2.GetHeight(1000);
|
||||
}
|
||||
BeepExclamation();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue