Bookstore

 Computer Math and Games in Pascal (preview) Lazarus Handbook

Author Topic: Checking Speed of SynEdit Highlighters  (Read 90060 times)

Morton

• Full Member
• Posts: 111
Re: Checking Speed of SynEdit Highlighters
« Reply #150 on: November 05, 2013, 07:20:48 pm »
Your test with using "random" is not a guarantee, but could be modified to iterate all possible words.

Would be a bit less than  (number of different chars)  *  (maximal length) * (medium length).
For Pascal less than 2548 different strings, including the keywords.

implementation  = 14 char long

26^14 = 64509974703297150976 (if I copied it correctly from my calculator)

+ 26^13 + 26 ^ 12 ....

I would realy have expected more from someone insisting to be a professional.

That is a moronic repetition of formulas once swallowed without understanding.
Oh Herr schmeiß hirn ra.
Oh Lord throw some brain down here.

Is it too much to ask, first to reflect by using some real brainpower.
I cannot see any professional approach here.
What I see is plainly childish behaviour.
« Last Edit: November 05, 2013, 07:41:58 pm by Morton »

Edson

• Hero Member
• Posts: 1084
Re: Checking Speed of SynEdit Highlighters
« Reply #151 on: November 05, 2013, 07:43:23 pm »
Morton, When are you going to accept you are wrong.?

Failed in your code (several times), failed in your formula, and still insult us.
For respect, I am not going to insult you.

I prefer to ignore all your attacks, and no waste my time checking your code.
Lazarus 2.0.6 - FPC 3.0.4 - x86_64-win64 on  Windows 8

Morton

• Full Member
• Posts: 111
Re: Checking Speed of SynEdit Highlighters
« Reply #152 on: November 05, 2013, 08:20:42 pm »
Failed in your code (several times)

I was just hoping someone would see the obvious solution.
I am a bit lazy.
If you do not check, then you may miss an opportunity to learn something.
But that is not my problem.

With the 1 million random strings:
On average ItemOfByHash is only called about three times more as keywords have been found.
Pretty good ratio, which would be better for real code.
Obviously my formula does not fail,
the computed amount is rather much to large.
« Last Edit: November 06, 2013, 02:14:20 pm by Morton »

Morton

• Full Member
• Posts: 111
Re: Checking Speed of SynEdit Highlighters
« Reply #153 on: November 06, 2013, 01:16:41 pm »
On real code ItemOf or ItemOfByHash are called only a few times more
than keywords are found.
For a file containing at least one occurrence of every keyword there will likely be
never more than 100 different hashes created, including the hashes for the keywords.

which reduces the amount of possible identifiers a huge lot.
The list of keywords creates another set of rules for identifiers which could be possibly keywords.
Finally there will be only slightly more identifiers which could be possibly keywords,
than keywords.

For such a small amount it is possible to create unique hashes.

For all this very obvious reasons  26^14 = 64509974703297150976 is just ridiculous.
I cannot understand how someone could ever come up with this.

Sorry, should have been ItemOf or ItemOfByHash instead of IsKeyword or IsKeywordByHash.
Fixed.
« Last Edit: November 06, 2013, 02:16:33 pm by Morton »

Morton

• Full Member
• Posts: 111
Re: Checking Speed of SynEdit Highlighters
« Reply #154 on: November 07, 2013, 04:52:39 pm »
Has anyone had a close look at the last version of the matcher ?

Morton

• Full Member
• Posts: 111
Re: Checking Speed of SynEdit Highlighters
« Reply #155 on: November 11, 2013, 07:49:51 pm »
I have modified the pascal highlighter to use the matcher and the keylist
Somewhere I made a mistake which prevents correct folding of subroutines.
The code becomes more readable, as only one key is handled per event.

irfanbagus

• Jr. Member
• Posts: 61
Re: Checking Speed of SynEdit Highlighters
« Reply #156 on: November 12, 2013, 07:20:42 am »
@Morton

this is what i did :

1.  reduce your hash function output to smallint.
reason : my pc not fast enough to search all combination with 32bit (cardinal) output.
but i also did :
2. use maximum keyword length 5 chars. pascal keyword need 14 char
3. find hash for keyword 'end' (12251)
4. try to find hash for all 2-5 chars ('a'-'z') combination which equal to 12251.

result :
find 185 combination

uqdc=12251
wwje=12251
....
....
....
azlrz=12251
dfzwz=12251

with your original hash function (cardinal output) did not make any difference because all keyword combinations (14 char) bigger than cardinal capacity.

Morton

• Full Member
• Posts: 111
Re: Checking Speed of SynEdit Highlighters
« Reply #157 on: November 12, 2013, 07:58:39 am »
@Morton

this is what i did :

1.  reduce your hash function output to smallint.
reason : my pc not fast enough to search all combination with 32bit (cardinal) output.
but i also did :
2. use maximum keyword length 5 chars. pascal keyword need 14 char
3. find hash for keyword 'end' (12251)
4. try to find hash for all 2-5 chars ('a'-'z') combination which equal to 12251.

result :
find 185 combination

uqdc=12251
wwje=12251
....
....
....
azlrz=12251
dfzwz=12251

with your original hash function (cardinal output) did not make any difference because all keyword combinations (14 char) bigger than cardinal capacity.

None of these combinations will pass the matrix
and thus there will never be a hash generated for them.

irfanbagus

• Jr. Member
• Posts: 61
Re: Checking Speed of SynEdit Highlighters
« Reply #158 on: November 12, 2013, 08:52:42 am »
None of these combinations will pass the matrix
and thus there will never be a hash generated for them.

i am done. bye.

Morton

• Full Member
• Posts: 111
Re: Checking Speed of SynEdit Highlighters
« Reply #159 on: November 12, 2013, 09:01:04 am »
Gods themselves struggle in vain against stupidity.
Life is to short for such a waste of time.

Morton

• Full Member
• Posts: 111
Re: Checking Speed of SynEdit Highlighters
« Reply #160 on: November 12, 2013, 09:44:51 am »
None of these combinations will pass the matrix
and thus there will never be a hash generated for them.

i am done. bye.

you know, and can nothing.
Learn programming first, but likely you will fail.
How can one dare to show one's lack of everything in the public ?

procedure TForm1.Button1Click(Sender: TObject);
begin
Label1.Caption:= IntToStr(HashSmallInt(Edit1.Text));
Label2.Caption:= IntToStr(HashCardinal(Edit1.Text));
Label3.Caption:= IntToStr(HashQWord(Edit1.Text));
end;

function TForm1.HashSmallInt(const S: String): SmallInt;
var
P, P2: PChar;
begin
P:= PChar(S);
P2:= P + Length(S);
Result := 0;
while P < P2 do
begin
Result := Result shl 10 - Result shl 5 - Result + Ord(P^);
inc(P);
end;
end;

function TForm1.HashCardinal(const S: String): Cardinal;
var
P, P2: PChar;
begin
P:= PChar(S);
P2:= P + Length(S);
Result := 0;
while P < P2 do
begin
Result := Result shl 10 - Result shl 5 - Result + Ord(P^);
inc(P);
end;
end;

function TForm1.HashQWord(const S: String): QWord;
var
P, P2: PChar;
begin
P:= PChar(S);
P2:= P + Length(S);
Result := 0;
while P < P2 do
begin
Result := Result shl 10 - Result shl 5 - Result + Ord(P^);
inc(P);
end;
end;

BTW for QWord the hash could be made much faster by first simply moving up to 8 chars
into the QWord and starting bitwise from the ninth.
A set could take even 32 chars.
Would work best for case sensitive languages,
but insensitive would be no problem too.
« Last Edit: November 12, 2013, 11:00:41 am by Morton »

JanRoza

• Hero Member
• Posts: 585
Re: Checking Speed of SynEdit Highlighters
« Reply #161 on: November 12, 2013, 12:44:31 pm »
Maybe it's time a moderator took a look at this topic as I think some people really show they have no manners at all.
Is it so hard to discuss something without insulting the other?
Morton, please learn some manners and try to behave in this forum.
The way you behave now I think more and more people will just ignore you as they have had enough of your insults.
« Last Edit: November 12, 2013, 12:53:23 pm by JanRoza »
OS: Windows 10 (64 bit) / Linux Mint (64 bit)
Laz: Lazarus 2.0.10 FPC 3.2.0
CodeTyphon 7.2 FPC 3.3.1

Morton

• Full Member
• Posts: 111
Re: Checking Speed of SynEdit Highlighters
« Reply #162 on: November 12, 2013, 01:01:20 pm »
Maybe it's time a moderator took a look at this topic as I think some people really show they have no manners at all.
Is it so hard to discuss something without insulting the other?
Morton, please learn some manners and try to behave in this forum.
The way you behave now I think more annd more people will just ignore you as they have had enough of your insults.

The code above shows that irfanbagus has insulted me and himself.
Obviously he does not know that the result of bitwise manipulation of data types depends on the data types.
Thats very very basic knowledge.
irfanbagus has in very clear words told me that I am a moron,
but without being aware he has told something not flattering about himself.

I have only stated the obvious.
That is by no means an insult.
« Last Edit: November 12, 2013, 01:14:58 pm by Morton »

BBaz

• Newbie
• Posts: 4
Re: Checking Speed of SynEdit Highlighters
« Reply #163 on: November 12, 2013, 06:53:43 pm »
I would not like to invalidate 20 pages of discussions in a forum but I think that you forgot 1 thing:
- lexing/parsing in an text editor (to get the lexical token) is not the same as lexing/parsing in a compiler (to get the grammatical syntax tree...)

1: in a text editor: when you change a char, only a page is re-lexed/re-parsed, in synEdit it'll also depend on the ranges
2: in a compiler: the whole stuff is lexed..tokenized...parsed...

So in synEdit, performances are not so important...many times when you change a line the whole document will not be rescanned...
For example, if you are editing a 50 000 linee  sourcecode file, and if you change a char, do you expect the whole stuff to be rescanned ?
...
No of course... only the screen range will be rescanned and maybe a bit of code before...

Morton

• Full Member
• Posts: 111
Re: Checking Speed of SynEdit Highlighters
« Reply #164 on: November 12, 2013, 07:04:30 pm »
...
No of course... only the screen range will be rescanned and maybe a bit of code before...

Usually only a single line will be scanned,
but some chars will cause a scan from the modified line to the end of the whole code.

The thread was started by one who felt urged to show how smart he is.
« Last Edit: November 12, 2013, 07:11:51 pm by Morton »