TFS API - slow foreach changeset iteration

最后都变了- 提交于 2019-12-24 05:13:12

问题


Question Background:

I am using the TFS api to query against a large range(1-600+) of files on my TFS server.

From each file I am collecting all of its ChangesetId's which are then collected in a list.

The code:

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:

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?


回答1:


The problem it takes so long is the "True" in your code:

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.

The parameter is repsonsible for filling the "Changes" property of a Changeset. Those Changes are holding MergeSources and ChangeType and so on.



来源:https://stackoverflow.com/questions/23109315/tfs-api-slow-foreach-changeset-iteration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!