Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
775c4ebc
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
775c4ebc
编写于
1月 24, 2020
作者:
S
Sam Harwell
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Replace PooledStopwatch with SharedStopwatch
上级
6cb854a5
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
73 addition
and
48 deletion
+73
-48
src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerExecutor.cs
...lers/Core/Portable/DiagnosticAnalyzer/AnalyzerExecutor.cs
+5
-6
src/Compilers/Core/Portable/InternalUtilities/SharedStopwatch.cs
...pilers/Core/Portable/InternalUtilities/SharedStopwatch.cs
+67
-0
src/Dependencies/PooledObjects/Microsoft.CodeAnalysis.PooledObjects.projitems
...ledObjects/Microsoft.CodeAnalysis.PooledObjects.projitems
+0
-1
src/Dependencies/PooledObjects/PooledStopwatch.cs
src/Dependencies/PooledObjects/PooledStopwatch.cs
+0
-41
src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj
...es/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj
+1
-0
未找到文件。
src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerExecutor.cs
浏览文件 @
775c4ebc
...
...
@@ -1448,10 +1448,10 @@ private void ExecuteAndCatchIfThrows_NoLock<TArg>(DiagnosticAnalyzer analyzer, A
{
_cancellationToken
.
ThrowIfCancellationRequested
();
PooledStopwatch
timer
=
null
;
SharedStopwatch
timer
=
default
;
if
(
_analyzerExecutionTimeMapOpt
!=
null
)
{
timer
=
PooledStopwatch
.
StartInstance
();
timer
=
SharedStopwatch
.
StartNew
();
// This call to Restart isn't required by the API, but is included to avoid measurement errors which
// can occur during periods of high allocation activity. In some cases, calls to Stopwatch
...
...
@@ -1468,12 +1468,11 @@ private void ExecuteAndCatchIfThrows_NoLock<TArg>(DiagnosticAnalyzer analyzer, A
analyze
(
argument
);
if
(
timer
!=
null
)
if
(
_analyzerExecutionTimeMapOpt
!=
null
)
{
timer
.
Stop
()
;
var
elapsed
=
timer
.
Elapsed
.
Ticks
;
StrongBox
<
long
>
totalTicks
=
_analyzerExecutionTimeMapOpt
.
GetOrAdd
(
analyzer
,
_
=>
new
StrongBox
<
long
>(
0
));
Interlocked
.
Add
(
ref
totalTicks
.
Value
,
timer
.
Elapsed
.
Ticks
);
timer
.
Free
();
Interlocked
.
Add
(
ref
totalTicks
.
Value
,
elapsed
);
}
}
catch
(
Exception
e
)
when
(
ExceptionFilter
(
e
))
...
...
src/Compilers/Core/Portable/InternalUtilities/SharedStopwatch.cs
0 → 100644
浏览文件 @
775c4ebc
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using
System
;
using
System.Diagnostics
;
namespace
Roslyn.Utilities
{
internal
struct
SharedStopwatch
{
private
static
readonly
Stopwatch
s_stopwatch
=
Stopwatch
.
StartNew
();
private
TimeSpan
_accumulated
;
private
TimeSpan
_started
;
public
readonly
TimeSpan
Elapsed
{
get
{
if
(
IsRunning
)
return
_accumulated
+
s_stopwatch
.
Elapsed
-
_started
;
return
_accumulated
;
}
}
public
readonly
long
ElapsedMilliseconds
=>
(
long
)
Elapsed
.
TotalMilliseconds
;
public
readonly
bool
IsRunning
=>
_started
!=
TimeSpan
.
Zero
;
public
static
SharedStopwatch
StartNew
()
{
var
result
=
new
SharedStopwatch
();
result
.
Start
();
return
result
;
}
public
void
Reset
()
{
Stop
();
_accumulated
=
TimeSpan
.
Zero
;
}
public
void
Restart
()
{
Reset
();
Start
();
}
public
void
Start
()
{
if
(!
IsRunning
)
{
_started
=
s_stopwatch
.
Elapsed
;
}
}
public
void
Stop
()
{
if
(
IsRunning
)
{
_accumulated
+=
s_stopwatch
.
Elapsed
-
_started
;
_started
=
TimeSpan
.
Zero
;
}
}
}
}
src/Dependencies/PooledObjects/Microsoft.CodeAnalysis.PooledObjects.projitems
浏览文件 @
775c4ebc
...
...
@@ -15,7 +15,6 @@
<Compile
Include=
"$(MSBuildThisFileDirectory)ObjectPool`1.cs"
/>
<Compile
Include=
"$(MSBuildThisFileDirectory)PooledDictionary.cs"
/>
<Compile
Include=
"$(MSBuildThisFileDirectory)PooledHashSet.cs"
/>
<Compile
Include=
"$(MSBuildThisFileDirectory)PooledStopwatch.cs"
/>
<Compile
Include=
"$(MSBuildThisFileDirectory)PooledStringBuilder.cs"
/>
</ItemGroup>
</Project>
\ No newline at end of file
src/Dependencies/PooledObjects/PooledStopwatch.cs
已删除
100644 → 0
浏览文件 @
6cb854a5
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using
System
;
using
System.Diagnostics
;
namespace
Microsoft.CodeAnalysis.PooledObjects
{
internal
class
PooledStopwatch
:
Stopwatch
{
private
static
readonly
ObjectPool
<
PooledStopwatch
>
s_poolInstance
=
CreatePool
();
private
readonly
ObjectPool
<
PooledStopwatch
>
_pool
;
private
PooledStopwatch
(
ObjectPool
<
PooledStopwatch
>
pool
)
{
_pool
=
pool
;
}
public
void
Free
()
{
Reset
();
_pool
?.
Free
(
this
);
}
public
static
ObjectPool
<
PooledStopwatch
>
CreatePool
()
{
ObjectPool
<
PooledStopwatch
>
pool
=
null
;
pool
=
new
ObjectPool
<
PooledStopwatch
>(()
=>
new
PooledStopwatch
(
pool
),
128
);
return
pool
;
}
public
static
PooledStopwatch
StartInstance
()
{
var
instance
=
s_poolInstance
.
Allocate
();
instance
.
Restart
();
return
instance
;
}
}
}
src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj
浏览文件 @
775c4ebc
...
...
@@ -27,6 +27,7 @@
<ItemGroup
Label=
"Linked Files"
>
<Compile
Remove=
"Storage\Sqlite\**\*.cs"
Condition=
"'$(DotNetBuildFromSource)' == 'true'"
/>
<Compile
Include=
"..\..\..\CodeStyle\Core\CodeFixes\FixAllContextHelper.cs"
Link=
"CodeFixes\FixAllOccurrences\FixAllContextHelper.cs"
/>
<Compile
Include=
"..\..\..\Compilers\Core\Portable\InternalUtilities\SharedStopwatch.cs"
Link=
"InternalUtilities\SharedStopwatch.cs"
/>
<Compile
Include=
"..\..\..\Compilers\Shared\DesktopAnalyzerAssemblyLoader.cs"
>
<Link>
Execution\Desktop\DesktopAnalyzerAssemblyLoader.cs
</Link>
</Compile>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录