Long story short. After profiling, this command takes 0,1% of the processing
var ChangesetList = TFSConnection.GetInstance().GetVersionControl().QueryHistory
(Path, VersionSpec.Latest,0, RecursionType.Full, "", null,
VersionSpec.Latest, Int32.MaxValue,true, false);
This one, 65,7%. (funny thing, all the processing inside consumes only 3%)
foreach (Changeset changeset in ChangesetList)
It takes several seconds until I get my list... What is happening? Why is it so slow iterating through the list?
Is there any faster way to do this ?
Edit: Plus, why can't I convert it directly to a List<Changeset> ?
The call to
VersionControlServer.QueryHistoryreturns anIEnumerable, so I assume it's like in LINQ to Objects and the actual query is executed as soon as you iterate over the IEnumerable (keyword: deferred execution).You can't assign the result to an List because the return value is the non generic Version of
IEnumerable. CallingCast<Changeset>()orOfType<Changeset>()on the result returns a genericIEnumerable<Changeset>.After that you can callToList()and get aList<Changeset>.ToList()iterates over theIEnumerable<T>so it's like the foreach and takes most of the time.The methods I mentioned are extension methods and are located in the System.Linq namespace.