yo B-Man je kan dkitTest wel doorlopen idd maar als new=old dan moet je effe VISUEEL controleren of het result correct is

en dat is in dat geval niet (weet niet met jouw nieuwe code).
Maar goed zoals vermeld is het dus niet meer een questie van copy's maar van zoeken waar een match zit. heb dus effe een nieuwe test geschreven en die kijkt ALLEEN naar find hits methode.
Results:
----------------------------------------------
Size Of Old: 7 / Size Of New: 4
testing with 720 characters and repeating test:10000
BMan 0.36 /ms, Found 300000 Matches
Onno 0.25 /ms, Found 300000 Matches
testing with 7200 characters and repeating test:1000
BMan 0.359 /ms, Found 300000 Matches
Onno 0.204 /ms, Found 300000 Matches
testing with 72000 characters and repeating test:100
BMan 0.406 /ms, Found 300000 Matches
Onno 0.25 /ms, Found 300000 Matches
----------------------------------------------
Size Of Old: 7 / Size Of New: 7
testing with 720 characters and repeating test:10000
BMan 0.328 /ms, Found 300000 Matches
Onno 0.219 /ms, Found 300000 Matches
testing with 7200 characters and repeating test:1000
BMan 0.343 /ms, Found 300000 Matches
Onno 0.219 /ms, Found 300000 Matches
testing with 72000 characters and repeating test:100
BMan 0.406 /ms, Found 300000 Matches
Onno 0.282 /ms, Found 300000 Matches
----------------------------------------------
Size Of Old: 7 / Size Of New: 12
testing with 720 characters and repeating test:10000
BMan 0.343 /ms, Found 300000 Matches
Onno 0.203 /ms, Found 300000 Matches
testing with 7200 characters and repeating test:1000
BMan 0.36 /ms, Found 300000 Matches
Onno 0.234 /ms, Found 300000 Matches
testing with 72000 characters and repeating test:100
BMan 0.422 /ms, Found 300000 Matches
Onno 0.281 /ms, Found 300000 Matches
edit:
[effe oisyn's syntaxer beproeven ;]
bovenstaand met volgende code...
Java:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
| public int findMatchesBMan(char[] aOriginal, char[] aFrom, char[] aTo)
{
final int tFromLength = aFrom.length;
final int tToLength = aTo.length;
final int tMaxIndex = aOriginal.length - tFromLength + 1;
int tHits = 0;
final char tFirst = aFrom[0];
int i = 0;
int j;
final int end = tFromLength - 1;
final char tLast = aFrom[end];
first:for (; i < tMaxIndex; i++)
{
if (aOriginal[i] != tFirst)
{
continue;
}
if (aOriginal[i + end] != tLast)
{
continue;
}
for (j = 0; j < tFromLength; j++)
{
if (aOriginal[i + j] != aFrom[j])
{
continue first;
}
}
tHits++;
}
return tHits;
}
public int findMatchesOnno(char[] aOriginal, char[] aFrom, char[] aTo)
{
final int tFromLength = aFrom.length;
final int tToLength = aTo.length;
final int tMaxIndex = aOriginal.length - tFromLength + 1;
int tHits = 0;
final char tFirst = aFrom[0];
int tIndex = 0;
int tSearchIndex;
nextChar:while (tIndex < tMaxIndex) //ugly ? yes but nice :)
{
if (aOriginal[tIndex++] != tFirst)
{
continue;
}
tSearchIndex = 1; //restart search
while (tSearchIndex < tFromLength)
{
if (aOriginal[tIndex++] != aFrom[tSearchIndex++]) //is ++Int faster???
{
continue nextChar; //restart search
}
}
tHits++;
}
return tHits;
} |
dus hier heb ik de gewoon de search loops uitgehaald de string wordt NIET veranderd en is dus een find hits's. (met jouw laatste versie die ik trouwens ook nog wat heb geoptimaliseerd ivm temp vars etc...)
[
Voor 35% gewijzigd door
hobbit_be op 10-03-2003 17:29
]