初始GET比获取TF.exe需要的时间更长

时间:2019-09-25 13:06:50

标签: c# tfs azure-devops

我正在使用以下代码下载文件:

TfsTeamProjectCollection tfsTeamProjectCollection 
    = new TfsTeamProjectCollection(new Uri("http://local.DevOps-TFS/tfs/resourceCollection"));

Workspace ws 
    = Workstation.Current.GetAllLocalWorkspaceInfo()[0].GetWorkspace(tfsTeamProjectCollection);

Stopwatch s = new Stopwatch();
s.Start();
ws.Get(new string[] { "$/REPO/file.cpp" }, VersionSpec.Latest, RecursionType.OneLevel, GetOptions.GetAll);
s.Stop();
Console.WriteLine(s.Elapsed.TotalSeconds);

Stopwatch s = new Stopwatch();
s.Start();
ws.Get(new string[] { "$/REPO/file2.cpp" }, VersionSpec.Latest, RecursionType.OneLevel, GetOptions.GetAll);
s.Stop();
Console.WriteLine(s.Elapsed.TotalSeconds);

这很好用,除了第一个GET需要9秒,第二个GET需要0.05秒。 不管要获取什么文件和获取多少文件,第一个文件总是比后面的文件花费更长的时间。

奇怪的是:使用TF.exe获取文件的速度更快,第一个获取的速度与其他文件一样快。

tf vc get $/REPO/file.cpp /force

我已经调试到TFS-API源代码,问题是API等待rest-api调用完成的那一刻。我认为身份验证存在问题,但是我无法弄清楚到底是什么错误。 我还调试了TF.exe,以查看它们如何进行身份验证,但是我没有找到任何特定的东西,并且它们使用的代码与上述相同。但是不知何故,从TF.exe中调用的rest-api调用比我的应用程序中的rest-api调用快得多。

我们正在使用TFS版本16。 有关如何继续的任何建议?

0 个答案:

没有答案