[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to count the number of occurrences of a character in a string?
From: |
Joost Kremers |
Subject: |
Re: How to count the number of occurrences of a character in a string? |
Date: |
13 Oct 2015 22:44:58 GMT |
User-agent: |
slrn/1.0.1 (Linux) |
Kaushal Modi wrote:
> . Updated https://gist.github.com/kaushalmodi/ab487f63727381179f61
You should byte-compile them. Makes the difference between cl-count and
the rest even bigger.
These are the results from only one run (each function called 100000
times), but I get similar results when I repeat the test:
,----
| cl-count 0.697451
| count-char-in-string-cl-count 0.743856
| count-char-in-string-mapcar 2.196961
| count-char-in-string-mapc 1.817378
| count-char-in-string-cdr 1.669147
| count-char-in-string-string-match 3.815134
`----
(I left out split-string as it produces the wrong result when the char
being counted appears twice in a row.)
The cl-count vs. count-char-in-string-cl-count are a direct call to
cl-count vs. cl-count wrapped in a function. There is obviously some
overhead to the additional function call, but even then cl-count wins
hands down.
Code is here:
https://gist.github.com/joostkremers/0e07a35c85758a2fcb52
--
Joost Kremers joostkremers@fastmail.fm
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)
- Re: How to count the number of occurrences of a character in a string?, (continued)
- Re: How to count the number of occurrences of a character in a string?, Kaushal Modi, 2015/10/15
- Re: How to count the number of occurrences of a character in a string?, Eli Zaretskii, 2015/10/15
- Re: How to count the number of occurrences of a character in a string?, Eli Zaretskii, 2015/10/13
- Re: How to count the number of occurrences of a character in a string?, Kaushal Modi, 2015/10/15
- Re: How to count the number of occurrences of a character in a string?, Eli Zaretskii, 2015/10/13
- Re: How to count the number of occurrences of a character in a string?, Kaushal Modi, 2015/10/13
- Re: How to count the number of occurrences of a character in a string?, Eli Zaretskii, 2015/10/13
- Re: How to count the number of occurrences of a character in a string?, Kaushal Modi, 2015/10/13
- Message not available
- Re: How to count the number of occurrences of a character in a string?, Brendan Halpin, 2015/10/13
- Re: How to count the number of occurrences of a character in a string?, Kaushal Modi, 2015/10/13
- Message not available
- Re: How to count the number of occurrences of a character in a string?,
Joost Kremers <=
- Re: How to count the number of occurrences of a character in a string?, Oleh Krehel, 2015/10/14
- Re: How to count the number of occurrences of a character in a string?, Eli Zaretskii, 2015/10/14
- Re: How to count the number of occurrences of a character in a string?, Michael Heerdegen, 2015/10/13
- Re: How to count the number of occurrences of a character in a string?, Charles Curley, 2015/10/15
- Re: How to count the number of occurrences of a character in a string?, Noam Postavsky, 2015/10/15
- Re: How to count the number of occurrences of a character in a string?, Kaushal Modi, 2015/10/14
Re: How to count the number of occurrences of a character in a string?, Emanuel Berg, 2015/10/13
Re: How to count the number of occurrences of a character in a string?, Joost Kremers, 2015/10/12