import java.util.* import kotlin.system.measureNanoTime // measuring different ways of cloning a map // tolist_tomap: 100 rounds 14032511 ns, 140325 per round // time_hashmap: 100 rounds 4515198 ns, 45151 per round fun main(args: Array) { println("measuring different ways of cloning a map") val map = (0..100).associateBy({"$it"}, {"---$it----"}) val clones = mutableListOf>() val N = 100 val time_tolist_tomap = measureNanoTime { for(i in 1..N) { clones.add(map.toList().toMap()) } } println("tolist_tomap: $N rounds $time_tolist_tomap ns, ${time_tolist_tomap / N} per round") clones.clear() val time_hashmap = measureNanoTime { for(i in 1..N) { clones.add(HashMap(map)) } } println("time_hashmap: $N rounds $time_hashmap ns, ${time_hashmap / N} per round") }