Recent

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

Morton

  • Full Member
  • ***
  • Posts: 111
Re: Checking Speed of SynEdit Highlighters
« Reply #135 on: November 05, 2013, 04:12:46 pm »
Quote
Hashes will only be created for strings within the min and max lenths of the keywords.


So you also compare the length, in addition to the hash value?
NO.


Those 2 statements directly contradict each other.

No they do not, as the length is only used for exclusion, not for comparing.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: Checking Speed of SynEdit Highlighters
« Reply #136 on: November 05, 2013, 04:19:03 pm »
Lets agree to disagree.

All else seems to lead nowhere.

Morton

  • Full Member
  • ***
  • Posts: 111
Re: Checking Speed of SynEdit Highlighters
« Reply #137 on: November 05, 2013, 04:31:31 pm »
Lets agree to disagree.

All else seems to lead nowhere.

It is plain and simple mathematics.
If you cannot do the mathematics yourself then
admit it and ask a mathematician if my claim is true.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: Checking Speed of SynEdit Highlighters
« Reply #138 on: November 05, 2013, 04:52:20 pm »
Ok, I have tried to keep this professional. If I have failed at any point up to here, I shall apologize.

As for your last statement (and the professional part ends here, no apologies for the following will be given):

I do not need to defend my skills. Those who know me (and I) will have their own judgement about my abilities.

As for you, if you are unable to close an argument without malicious insinuation about the other, then you have done well.

Please feel free to add any further reply. I shall disregard it.

Morton

  • Full Member
  • ***
  • Posts: 111
Re: Checking Speed of SynEdit Highlighters
« Reply #139 on: November 05, 2013, 05:02:35 pm »
@Martin_fr
So far you have not made any serious attempt to prove me wrong.
Does not look professional for me.

Edson

  • Hero Member
  • *****
  • Posts: 1301
Re: Checking Speed of SynEdit Highlighters
« Reply #140 on: November 05, 2013, 05:07:37 pm »
@Morton

Can you show a little of humilty?

We are trying to be patient with you.

For all the time I know,  Martin is very professional.
« Last Edit: November 05, 2013, 05:19:21 pm by Edson »
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Edson

  • Hero Member
  • *****
  • Posts: 1301
Re: Checking Speed of SynEdit Highlighters
« Reply #141 on: November 05, 2013, 05:16:13 pm »
By the way, I'm good on mathematics (but not in English) and your formula is wrong:

The maximal amount of different strings for a given range of lenths is not:

(number of different chars)  *  (maximal length) * (medium length).

It is:

(number of different chars)^n + (number of different chars)^(n+1) + ... +  (number of different chars) ^m

Where:
n -> minimal length
m -> maximal length

And it grows to the infinite with just a little "n" and "m".
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Morton

  • Full Member
  • ***
  • Posts: 111
Re: Checking Speed of SynEdit Highlighters
« Reply #142 on: November 05, 2013, 05:39:49 pm »
By the way, I'm good on mathematics (but not in English) and your formula is wrong:

At last one has noticed my mistake, which I did not by accident.
It clearly showed that there was not made any attempt to follow my arguments,
eg. by checking my formula.
Yours is wrong too.
« Last Edit: November 05, 2013, 06:25:25 pm by Morton »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: Checking Speed of SynEdit Highlighters
« Reply #143 on: November 05, 2013, 06:13:45 pm »
Lets ignore the question, if "excluding words of certain length" is "taking the length into comparison" or not. It does not matter.

What matters is, that it lead to a misunderstanding, and that some of my statements while this misunderstanding lasted, where based on that words of any length would be hashed.

Yes I did not read the formula. For all I can see, the exact formula does not matter.

What matters is, for any hash that results in a hash value in a finite range (e.g. the hash value is a 32 or 64 bit integer):

1) If words of arbitrary length (and that would mean an infinite amount of possible words) would be hashed, then to any chosen word, there may be another word with the same value.

2) If (as now clarified) only words within a specified range of lengths are  used, then the amount of words is finite [1] too. Within such are finite list of words (even if the list has more entries, than there are hash values), a hash can be found, that will for a given subset of those words (the pascal identifiers) produce hash values, that are not produced by any other word in the full list.

[1] and finite is all that matters, hence I did not bother with the formula, and still do not.


I have not tested your hash, if it fulfils the 2nd point. It may well do.
Your test with using "random" is not a guarantee, but could be modified to iterate all possible words.

----------------
Remains the point, what happens if a new keyword is added.

I assume you use an int32 or int64? In which case the total amount of words is bigger than the amount of hash values, so outside the current keyword-list there are clashes (but they do not harm).

If the new keyword is found to have a clash with any other random word from the full list, then you need to find a  new hash algorithm (or enable comparing the word itself, but that was what you try to avoid).

To me, the chance that I may have to redo the hash algorithm, falls under undesired maintenance cost.
On that you may disagree, but then everyone has to make there own decision what they see as maintainable (so long as it is ones own code / in a team different rules apply)



Morton

  • Full Member
  • ***
  • Posts: 111
Re: Checking Speed of SynEdit Highlighters
« Reply #144 on: November 05, 2013, 06:26:36 pm »
Sorry Edson, but again you are not nearly as smart as you belive.

Example:
Lenght 2:  (number of different chars)  * 2 eg.  26*2 = 52.
Lenght 3:  (number of different chars)  * 3 eg.  26*3 = 78
Lenght 4:  (number of different chars)  * 4 eg.  26*4 = 104
Lenght 5:  (number of different chars)  * 5 eg.  26*5 = 130
Lenght 6:  (number of different chars)  * 6 eg.  26*6 = 156

Sumary                                                                           520

(number of different chars)  *  (maximal length) * (medium length).
Eg. 26 * 6*4 = 624.

The result tends to be rather to large.
which makes the formula a safe approximation :D

Morton

  • Full Member
  • ***
  • Posts: 111
Re: Checking Speed of SynEdit Highlighters
« Reply #145 on: November 05, 2013, 06:32:57 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.

Edson

  • Hero Member
  • *****
  • Posts: 1301
Re: Checking Speed of SynEdit Highlighters
« Reply #146 on: November 05, 2013, 06:39:34 pm »
@Morton,

Review the formula:

Quote
(number of different chars)^n + (number of different chars)^(n+1) + ... +  (number of different chars) ^m

The symbol "^" mean exponent, "powered at".

I wanted to express that like a summatory of a serie, but it would have more confused.
« Last Edit: November 05, 2013, 06:41:57 pm by Edson »
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Edson

  • Hero Member
  • *****
  • Posts: 1301
Re: Checking Speed of SynEdit Highlighters
« Reply #147 on: November 05, 2013, 06:45:03 pm »
Example:

Lenght 2:  (number of different chars)  ^ 2 eg.  26^2 = 676.
Lenght 3:  (number of different chars)  ^ 3 eg.  26^3 = 17576
Lenght 4:  (number of different chars)  ^ 4 eg.  26^4 = 456976
Lenght 5:  (number of different chars)  ^ 5 eg.  26^5 = 11881376
Lenght 6:  (number of different chars)  ^ 6 eg.  26^6 = 308915776

Sumary                                                                           A LOT!!!!!
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: Checking Speed of SynEdit Highlighters
« Reply #148 on: November 05, 2013, 07:04:38 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.

Please see Edson's formula.
 implementation  = 14 char long

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

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

Morton

  • Full Member
  • ***
  • Posts: 111
Re: Checking Speed of SynEdit Highlighters
« Reply #149 on: November 05, 2013, 07:14:26 pm »
Lenght 2:  (number of different chars)  ^ 2 eg.  26^2 = 676.
Lenght 3:  (number of different chars)  ^ 3 eg.  26^3 = 17576
Lenght 4:  (number of different chars)  ^ 4 eg.  26^4 = 456976
Lenght 5:  (number of different chars)  ^ 5 eg.  26^5 = 11881376
Lenght 6:  (number of different chars)  ^ 6 eg.  26^6 = 308915776

Sumary                                                                           A LOT!!!!!

ROFL .
That realy hurts.  :'(

Did you never have learned to use your brain and not to rely on things you have swallowed once without reflection.

Close to 100% (more than 99.99% ) can be excluded before a hasch needs to be computed.

The correct formula for the amount of those who cannot be as easily excluded is:
(number of different chars)  *  (maximal length) * (((maximal length) div 2)+1) -
(number of different chars)  * (minimal length-1) * (((minimal length-1) div 2)+1) .

But this amount can be reduced significantly too.

Edson: I would reccoment you to use your brain and not simply repeat  formulas without thinking, which someone has trown towards you at school.
« Last Edit: November 05, 2013, 07:39:32 pm by Morton »

 

TinyPortal © 2005-2018