[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: |
Kaushal Modi |
Subject: |
Re: How to count the number of occurrences of a character in a string? |
Date: |
Tue, 13 Oct 2015 16:41:13 -0400 |
Just tried that, mapc is the best alternative after cl-count.
Updated the results and code at
https://gist.github.com/kaushalmodi/ab487f63727381179f61
--
Kaushal Modi
On Tue, Oct 13, 2015 at 4:17 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>> From: Kaushal Modi <kaushal.modi@gmail.com>
>> Date: Tue, 13 Oct 2015 15:56:57 -0400
>> Cc: Help Gnu Emacs mailing list <help-gnu-emacs@gnu.org>
>>
>> Now I see some convergence in the results and this was the conclusion,
>> fastest to slowest
>>
>> 1. cl-count
>> 2. Eli's cdr approach
>> 3. My string-match-p approach
>>
>> Code: https://gist.github.com/ab487f63727381179f61
>> Raw results:
>>
>> 1000 executions of string-match-p approach took 0.047036 seconds
>> 1000 executions of cl-count approach took 0.036476 seconds
>> 1000 executions of cdr approach took 0.043735 seconds
>> nil
>> 1000 executions of string-match-p approach took 0.046918 seconds
>> 1000 executions of cl-count approach took 0.035476 seconds
>> 1000 executions of cdr approach took 0.202394 seconds
>> nil
>
> Looks like 1000 loops is too few: your measurements hit clock
> quantization error, and also some background activities affect the
> results. I suggest to try 10000 iterations.
>
> Also, did you actually try 'mapc', per my second suggestion?
>
- 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?, Nick Dokos, 2015/10/12
- Re: How to count the number of occurrences of a character in a string?, Stefan Monnier, 2015/10/12
- 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?, 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 <=
- 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, 2015/10/13
- 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