You could use frequencies:
user=> (frequencies (map #(quot % 1000) epochs))
{1405060202 1, 1405060201 8, 1405060200 1, 1405060205 1}
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note t
On Thursday, July 17, 2014 8:49:12 AM UTC-4, empt...@gmail.com wrote:
>
> Hi,
>
> I have a list of epoch times which map to HTTP requests.
>
> '(1405060202611
> 1405060201157
> 1405060201361
> 1405060201261
> 1405060200391
> 1405060201458
> 1405060201705
> 1405060201058
> 1405060205062
> 14050602
You need not reverse the list for counting requests per second.
If the data is in sorted order, you can start with any direction.
Take the first as the base and keep separating untill you get 1 second or X
units like 1000 milliseconds if your data is in milliseconds.
The count would be an item of
As a start, you could use group-by with a function that squashes together
items that fall in the same second and then count the size of each value.
(reduce-kv (fn [c k v] (assoc c k (count v))) {} (group-by #(quot % 1000)
epochs))
;=> {1405060205 1, 1405060200 1, 1405060201 8, 1405060202 1}
-