Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
ikopylov committed May 17, 2017
2 parents 04c27a7 + 426465f commit 4d156b6
Showing 9 changed files with 55 additions and 29 deletions.
3 changes: 3 additions & 0 deletions ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v2.1.2 (17.05.2017)
- Performance: avoid closure creation in MultiInstanceCategory

v2.1.1 (30.03.2016)
- Escaping points and spaces in Instance and Counter names for Graphite counters
- TimeCounterTimer: group completion support
Original file line number Diff line number Diff line change
@@ -64,7 +64,11 @@ public override InstanceInMultiInstanceCategory this[string instanceName]
{
get
{
return _instances.GetOrAdd(instanceName, (name) => new CompositeInstanceInMultiInstanceCategory(this, name, _wrappedCategories.Select(wc => wc[name])));
CompositeInstanceInMultiInstanceCategory result = null;
if (!_instances.TryGetValue(instanceName, out result))
result = _instances.GetOrAdd(instanceName, new CompositeInstanceInMultiInstanceCategory(this, instanceName, _wrappedCategories.Select(wc => wc[instanceName])));

return result;
}
}

Original file line number Diff line number Diff line change
@@ -112,6 +112,21 @@ internal sealed override void InitCounters()
}


/// <summary>
/// Создаёт новый инстанс с добавлением во внутреннюю категорию
/// </summary>
/// <param name="name">Имя инстанса</param>
/// <returns>Инстанс</returns>
private T CreateInstanceWithName(string name)
{
var inst = new T();

var category = _category[name];
inst.InitInstance(this, category, _counters);

return inst;
}

/// <summary>
/// Получение или создание инстанса
/// </summary>
@@ -121,17 +136,11 @@ public T this[string instanceName]
{
get
{
var instance = _instances.GetOrAdd(instanceName, (name) =>
{
var inst = new T();

var category = _category[instanceName];
inst.InitInstance(this, category, _counters);

return inst;
});
T result;
if (!_instances.TryGetValue(instanceName, out result))
result = _instances.GetOrAdd(instanceName, CreateInstanceWithName(instanceName));

return instance;
return result;
}
}

Original file line number Diff line number Diff line change
@@ -60,7 +60,11 @@ public override InstanceInMultiInstanceCategory this[string instanceName]
{
get
{
return _instances.GetOrAdd(instanceName, (name) => new InternalInstanceInMultiInstanceCategory(this, name));
InternalInstanceInMultiInstanceCategory result = null;
if (!_instances.TryGetValue(instanceName, out result))
result = _instances.GetOrAdd(instanceName, new InternalInstanceInMultiInstanceCategory(this, instanceName));

return result;
}
}

Original file line number Diff line number Diff line change
@@ -113,11 +113,14 @@ public override InstanceInMultiInstanceCategory this[string instanceName]
{
get
{
return _instances.GetOrAdd(instanceName, (name) =>
{
_isChildInstancesChanged = true;
return new NetInstanceInMultiInstanceCategory(this, name);
});
NetInstanceInMultiInstanceCategory result = null;
if (!_instances.TryGetValue(instanceName, out result))
{
_isChildInstancesChanged = true;
result = _instances.GetOrAdd(instanceName, new NetInstanceInMultiInstanceCategory(this, instanceName));
}

return result;
}
}

2 changes: 1 addition & 1 deletion src/Qoollo.PerformanceCounters/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.1.1")]
[assembly: AssemblyVersion("2.1.2")]
//[assembly: AssemblyFileVersion("1.0.0.0")]
Original file line number Diff line number Diff line change
@@ -12,9 +12,8 @@
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Library for collecting and tracking performance metrics in your .NET applications.</description>
<releaseNotes>
v2.1.1 (30.03.2016)
- Escaping points and spaces in Instance and Counter names for Graphite counters
- TimeCounterTimer: group completion support
v2.1.2 (17.05.2017)
- Performance: avoid closure creation in MultiInstanceCategory
</releaseNotes>
<copyright>Copyright 2014</copyright>
<tags>Qoollo PerformanceCounters PerformanceCounter PerfCounters Performance Perf Counters Counter Health Profiling Monitoring perfmon Graphite</tags>
Original file line number Diff line number Diff line change
@@ -59,7 +59,10 @@ public override InstanceInMultiInstanceCategory this[string instanceName]
{
get
{
var result = _instances.GetOrAdd(instanceName, (name) => new WinInstanceInMultiInstanceCategory(this, name));
WinInstanceInMultiInstanceCategory result = null;
if (!_instances.TryGetValue(instanceName, out result))
result = _instances.GetOrAdd(instanceName, new WinInstanceInMultiInstanceCategory(this, instanceName));

if (result.State == WinCategoryState.Created && State == WinCategoryState.Initialized)
result.Init();

Original file line number Diff line number Diff line change
@@ -99,13 +99,14 @@ public override InstanceInMultiInstanceCategory this[string instanceName]
{
get
{
var result = _instances.GetOrAdd(instanceName, (name) =>
{
if (!HasWinInstance(instanceName))
throw new CategoryCreationException("Can't get not existed instance in mode 'UseOnlyExisted'. Category: " + this.ToString() + ", Instance: " + instanceName);

return new WinInstanceInMultiInstanceCategory(this, name);
});
WinInstanceInMultiInstanceCategory result = null;
if (!_instances.TryGetValue(instanceName, out result))
{
if (!HasWinInstance(instanceName))
throw new CategoryCreationException("Can't get not existed instance in mode 'UseOnlyExisted'. Category: " + this.ToString() + ", Instance: " + instanceName);

result = new WinInstanceInMultiInstanceCategory(this, instanceName);
}

if (result.State == WinCategoryState.Created)
result.Init();

0 comments on commit 4d156b6

Please sign in to comment.