You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sw=Stopwatch.StartNew();sw.Start();for(intj=0;j<100;j++){List<int>insert_table=newList<int>();for(inti=0;i<10000;i++)insert_table.Add(i);}sw.Stop();Console.WriteLine(String.Format("test_insert_array, Time taken: {0}ms",sw.Elapsed.TotalMilliseconds));Dictionary<string,int>map=newDictionary<string,int>();List<int>list=newList<int>();List<int>shuffle=newList<int>();int[]array=newint[10000];for(inti=0;i<10000;i++){map[""+i]=i;list.Add(i);array[i]=i;shuffle.Add(i);}for(inti=1;i<5000;i++){Randomrnd=newRandom();intj=rnd.Next(0,i);intrep=10000-1-j;inttmp=shuffle[rep];shuffle[rep]=shuffle[j];shuffle[j]=tmp;}sw=Stopwatch.StartNew();sw.Start();for(intj=0;j<100;j++){for(inti=0;i<10000;i++){inta=list[shuffle[i]];//int a = list[i];}}sw.Stop();Console.WriteLine(String.Format("test_random_index_list, Time taken: {0}ms",sw.Elapsed.TotalMilliseconds));sw=Stopwatch.StartNew();sw.Start();for(intj=0;j<100;j++){for(inti=0;i<10000;i++){//int a = list[shuffle[i]];inta=list[i];}}sw.Stop();Console.WriteLine(String.Format("test_range_index_list, Time taken: {0}ms",sw.Elapsed.TotalMilliseconds));sw=Stopwatch.StartNew();sw.Start();for(intj=0;j<100000;j++){inta1=list[0];inta2=list[9999];inta3=list[1500];inta4=list[3500];inta5=list[7000];}sw.Stop();Console.WriteLine(String.Format("test_some_index_list, Time taken: {0}ms",sw.Elapsed.TotalMilliseconds));sw=Stopwatch.StartNew();sw.Start();for(intj=0;j<100;j++){for(inti=0;i<10000;i++){// int a = array[shuffle[i]];inta=array[i];}}sw.Stop();Console.WriteLine(String.Format("test_random_index_array, Time taken: {0}ms",sw.Elapsed.TotalMilliseconds));sw=Stopwatch.StartNew();sw.Start();for(intj=0;j<100;j++){foreach(intainlist){intva=a;//int b = entry.Value;}}sw.Stop();Console.WriteLine(String.Format("test_iterate_list, Time taken: {0}ms",sw.Elapsed.TotalMilliseconds));sw=Stopwatch.StartNew();sw.Start();for(intj=0;j<100;j++){for(inti=0;i<list.Count;i++){intva=list[i];//int b = entry.Value;}}sw.Stop();Console.WriteLine(String.Format("test_for_list, Time taken: {0}ms",sw.Elapsed.TotalMilliseconds));sw=Stopwatch.StartNew();sw.Start();for(intj=0;j<100;j++){foreach(intainarray){intva=a;//int b = entry.Value;}}sw.Stop();Console.WriteLine(String.Format("test_iterate_array, Time taken: {0}ms",sw.Elapsed.TotalMilliseconds));sw=Stopwatch.StartNew();sw.Start();for(intj=0;j<100;j++){foreach(KeyValuePair<string,int>entryinmap){intb=entry.Value;}}sw.Stop();Console.WriteLine(String.Format("test_iterate_map, Time taken: {0}ms",sw.Elapsed.TotalMilliseconds));varkeys=map.Keys;sw=Stopwatch.StartNew();sw.Start();for(intj=0;j<100;j++){foreach(stringkeyinkeys){intb=map[key];}}sw.Stop();Console.WriteLine(String.Format("test_key_iterate_map, Time taken: {0}ms",sw.Elapsed.TotalMilliseconds));sw=Stopwatch.StartNew();sw.Start();for(intj=0;j<100;j++){foreach(stringkeyinkeys){stringvalue3=key;}}sw.Stop();Console.WriteLine(String.Format("test_iterate_keys, Time taken: {0}ms",sw.Elapsed.TotalMilliseconds));varvalues=map.Values;sw=Stopwatch.StartNew();sw.Start();for(intj=0;j<100;j++){foreach(intkeyinvalues){intvalue2=key;}}sw.Stop();Console.WriteLine(String.Format("test_iterate_values, Time taken: {0}ms",sw.Elapsed.TotalMilliseconds));
Configuration
all built with release configuration and run on windows x64 pc using mono6.10.0.
Data
runer with mono ./test.exe output:
test_insert_array, Time taken: 8.4756ms
test_random_index_list, Time taken: 3.6109ms
test_range_index_list, Time taken: 1.915ms
test_some_index_list, Time taken: 0.8582ms
test_random_index_array, Time taken: 1.7885ms
test_iterate_list, Time taken: 2.8108ms
test_for_list, Time taken: 2.0223ms
test_iterate_array, Time taken: 1.9559ms
test_iterate_map, Time taken: 9.6818ms
test_key_iterate_map, Time taken: 38.7477ms
test_iterate_keys, Time taken: 4.2465ms
test_iterate_values, Time taken: 5.1388ms
runer with mono --interp ./test.exe output:
test_insert_array, Time taken: 69.5591ms
test_random_index_list, Time taken: 96.2123ms
test_range_index_list, Time taken: 42.0968ms
test_some_index_list, Time taken: 19.1583ms
test_random_index_array, Time taken: 13.6853ms
test_iterate_list, Time taken: 58.5759ms
test_for_list, Time taken: 61.506ms
test_iterate_array, Time taken: 16.1444ms
test_iterate_map, Time taken: 181.1164ms
test_key_iterate_map, Time taken: 1455.6495ms
test_iterate_keys, Time taken: 78.4558ms
test_iterate_values, Time taken: 72.7544ms
Analysis
The text was updated successfully, but these errors were encountered:
Tagging subscribers to this area: @eiriktsarpalis, @jeffhandley
See info in area-owners.md if you want to be subscribed.
srxqds
changed the title
mono interpreter Dictionary<string, int> key index run slower than jit
mono interpreter System.Collections.Generic container run slower than jit
Sep 18, 2020
Tested with latest version of interp and the numbers are much better than this. The iterate benchmarks are still somewhat slower (up to 10x slower than jit), because interp doesn't currently support loop invariant hoisting. This optimization is currently not on the roadmap. Keeping track of it in #47520
Description
testcase code show below:
Configuration
all built with release configuration and run on windows x64 pc using mono6.10.0.
Data
runer with mono ./test.exe output:
runer with mono --interp ./test.exe output:
Analysis
The text was updated successfully, but these errors were encountered: