help-gnu-emacs
[Top][All Lists]
Advanced

[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: Eli Zaretskii
Subject: Re: How to count the number of occurrences of a character in a string?
Date: Tue, 13 Oct 2015 23:17:28 +0300

> 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?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]