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.QueryHistory
returns an IEnumerable
, 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
. Calling Cast<Changeset>()
or OfType<Changeset>()
on the result returns a generic IEnumerable<Changeset>.
After that you can call ToList()
and get a List<Changeset>
. ToList()
iterates over the IEnumerable<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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With