TFS API - 慢的foreach循环变更 [英] TFS API - slow foreach changeset iteration
问题描述
问题背景:的
Question Background:
我使用TFS API查询针对大范围(1- 600+)我的TFS服务器上的文件。
I am using the TFS api to query against a large range(1-600+) of files on my TFS server.
这是每一个文件,我收集它的所有ChangesetId的它们,然后在列表中收集的。
From each file I am collecting all of its ChangesetId's which are then collected in a list.
代码:的
The code:
这是我使用的代码。它工作正常生产的所有项目在QueryHistory方法指定参数的IEnumerable更改集列表中。
This is the code I'm using. It works correctly producing an IEnumerable change set list of all the items for the specified parameters in the QueryHistory method.
VersionSpec versionFrom = VersionSpec.ParseSingleSpec("C1", null);
VersionSpec versionTo = VersionSpec.Latest;
var changesetList = tfsDevItem.VersionControlServer.QueryHistory(tfsDevItem.ServerItem, VersionSpec.Latest, 0, RecursionType.None, null, versionFrom, versionTo, Int32.MaxValue, true, false);
item.VersionList = new List<int>();
//*****Very slow iteration*****
foreach (Changeset ChangesetId in changesetList)
{
item.VersionList.Add(ChangesetId.ChangesetId);
}
的问题:的
The Issue:
当通过在foreach的chagesetList,这是抽空每个变更循环为 难以置信的长。例如115文件需要 1 的分钟产生每个文件changesetID的列表。
When looping through each changeset in the chagesetList of the foreach, the time this is taking is incredibly long. For instance 115 files takes 1 minute to produce a list of each individual files changesetID's.
我可以改善这种?如果是这样如何
Can I improve this? If so how?
推荐答案
需要很长时间的问题是在你的代码中的真:
The problem it takes so long is the "True" in your code:
VAR changesetList = tfsDevItem.VersionControlServer.QueryHistory(tfsDevItem.ServerItem,VersionSpec.Latest,0,RecursionType.None,空,versionFrom,versionTo,Int32.MaxValue, 真正
,FALSE);
var changesetList = tfsDevItem.VersionControlServer.QueryHistory(tfsDevItem.ServerItem, VersionSpec.Latest, 0, RecursionType.None, null, versionFrom, versionTo, Int32.MaxValue, true
, false);
您只需要变更号码,以便通过假有
You only need the changeset number, so pass "false" there.
该参数是repsonsible用于填充的变更集。这些更改是抱着MergeSources和一changeType等
The parameter is repsonsible for filling the "Changes" property of a Changeset. Those Changes are holding MergeSources and ChangeType and so on.
这篇关于TFS API - 慢的foreach循环变更的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!