Created
          September 3, 2015 02:26 
        
      - 
      
- 
        Save scramjet/35727b062814a8afe8b7 to your computer and use it in GitHub Desktop. 
    Bench testing Clojure list comprehensions against map
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | user> (use 'criterium.core) | |
| nil | |
| user> (def sites (vec (for [i (range 1000)] {:stations (vec (for [j (range 10)] [{:id (str i "-" j)}]))}))) | |
| #'user/sites | |
| user> (bench (doall (mapcat (fn [site] (map :id (:stations site))) sites))) | |
| Evaluation count : 74280 in 60 samples of 1238 calls. | |
| Execution time mean : 802.413222 µs | |
| Execution time std-deviation : 10.087328 µs | |
| Execution time lower quantile : 786.940250 µs ( 2.5%) | |
| Execution time upper quantile : 823.245990 µs (97.5%) | |
| Overhead used : 1.685205 ns | |
| nil | |
| user> (bench (doall (for [site sites station (:stations site)] (:id station)))) | |
| Evaluation count : 72180 in 60 samples of 1203 calls. | |
| Execution time mean : 829.657186 µs | |
| Execution time std-deviation : 14.503025 µs | |
| Execution time lower quantile : 807.092634 µs ( 2.5%) | |
| Execution time upper quantile : 860.980596 µs (97.5%) | |
| Overhead used : 1.685205 ns | |
| Found 2 outliers in 60 samples (3.3333 %) | |
| low-severe 2 (3.3333 %) | |
| Variance from outliers : 6.2879 % Variance is slightly inflated by outliers | |
| nil | |
| user> (bench (doall (mapcat (fn [site] (map :id (:stations site))) sites))) | |
| Evaluation count : 75480 in 60 samples of 1258 calls. | |
| Execution time mean : 823.593130 µs | |
| Execution time std-deviation : 47.836024 µs | |
| Execution time lower quantile : 782.108014 µs ( 2.5%) | |
| Execution time upper quantile : 908.925568 µs (97.5%) | |
| Overhead used : 1.685205 ns | |
| Found 3 outliers in 60 samples (5.0000 %) | |
| low-severe 2 (3.3333 %) | |
| low-mild 1 (1.6667 %) | |
| Variance from outliers : 43.4368 % Variance is moderately inflated by outliers | |
| nil | |
| user> (bench (doall (for [site sites station (:stations site)] (:id station)))) | |
| Evaluation count : 76020 in 60 samples of 1267 calls. | |
| Execution time mean : 786.122713 µs | |
| Execution time std-deviation : 9.010751 µs | |
| Execution time lower quantile : 777.296567 µs ( 2.5%) | |
| Execution time upper quantile : 804.435049 µs (97.5%) | |
| Overhead used : 1.685205 ns | |
| Found 3 outliers in 60 samples (5.0000 %) | |
| low-severe 2 (3.3333 %) | |
| low-mild 1 (1.6667 %) | |
| Variance from outliers : 1.6389 % Variance is slightly inflated by outliers | |
| nil | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment