public Label(PProfSampleLabel labelItems, PProfItemCache builderCache, PProfProto.Label item) { Validate.NotNull(builderCache, nameof(builderCache)); Validate.NotNull(item, nameof(item)); this.Item = item; _valueKind = labelItems.ValueKind; _keyInfo = builderCache.GetOrCreateStringInfo(labelItems.Key ?? string.Empty); switch (labelItems.ValueKind) { case PProfSampleLabel.Kind.Number: _numValue = labelItems.NumberValue; _strValueOrNumUnitInfo = builderCache.GetOrCreateStringInfo(labelItems.NumberUnit ?? string.Empty); break; case PProfSampleLabel.Kind.String: _numValue = ProtoConstants.NumericValue.UnsetInt64; _strValueOrNumUnitInfo = builderCache.GetOrCreateStringInfo(labelItems.StringValue ?? string.Empty); break; case PProfSampleLabel.Kind.Unknown: default: throw new InvalidOperationException($"Cannot create a {nameof(PProfInfo)}.{nameof(Label)}," + $" because the {nameof(PProfSampleLabel.ValueKind)} of the" + $" specified {nameof(PProfSampleLabel)} is {labelItems.ValueKind}." + $" Either {PProfSampleLabel.Kind.Number} or {PProfSampleLabel.Kind.String} was expected." + $" (Did you use the default ctor for {nameof(PProfSampleLabel)}?" + " If so, use a different ctor overload.)"); } }
public ValueType(PProfSampleValueType valueTypeItems, PProfBuilder builder) { Validate.NotNull(builder, nameof(builder)); _typeInfo = builder.GetOrCreateStringInfo(valueTypeItems.Type ?? string.Empty); _unitInfo = builder.GetOrCreateStringInfo(valueTypeItems.Unit ?? string.Empty); }
private void AddToStringTable(PProfInfo.String stringInfo) { if (stringInfo != null && !stringInfo.IsIncludedInSession) { PProfBuildSessionState buildState = ValidOwnerBuildState; stringInfo.OffsetInStringTable = buildState.StringTable.Count; buildState.StringTable.Add(stringInfo); _profile.StringTable.Add(stringInfo.Item); } }
public Mapping(PProfProto.Mapping item, PProfInfo.String filenameInfo, PProfInfo.String buildIdInfo) { Validate.NotNull(item, nameof(item)); Validate.NotNull(filenameInfo, nameof(filenameInfo)); // buildIdInfo may be null this.Item = item; this.IsIncludedInSession = false; this.FilenameInfo = filenameInfo; this.BuildIdInfo = buildIdInfo; }
public Function(PProfProto.Function item, PProfInfo.String nameInfo, PProfInfo.String systemNameInfo, PProfInfo.String filenameInfo) { Validate.NotNull(item, nameof(item)); Validate.NotNull(nameInfo, nameof(nameInfo)); // systemNameInfo may be null // filenameInfo may be null this.Item = item; this.IsIncludedInSession = false; this.NameInfo = nameInfo; this.SystemNameInfo = systemNameInfo; this.FilenameInfo = filenameInfo; }
public void SetComment(string commentString) { if (_comment != null) { throw new InvalidOperationException($"The comment for this {nameof(PProfBuildSession)} was already set to {_comment}:" + $" impossible to change to {commentString}."); } _comment = OwnerBuilder.GetOrCreateStringInfo(commentString); if (_comment != null) { AddToStringTable(_comment); _profile.Comment.Add(_comment.OffsetInStringTable); } }
public PProfInfo.String GetOrCreateStringInfo(string stringItem) { if (stringItem == null) { return(null); } if (stringItem.Length == 0) { return(_emptyStringInfo); } if (!_strings.TryGetValue(stringItem, out PProfInfo.String stringInfo)) { stringInfo = new PProfInfo.String(stringItem); _strings.Add(stringItem, stringInfo); } return(stringInfo); }
internal void InitProfile() { PProfInfo.String emptyStringInfo = OwnerBuilder.EmptyStringInfo; PProfInfo.Mapping entrypointMappingInfo = OwnerBuilder.GetMainEntrypointMappingInfo(); // Empty string: AddToStringTable(emptyStringInfo); // Main entry-point mapping: if (entrypointMappingInfo != null) { AddToStringTable(entrypointMappingInfo.FilenameInfo); entrypointMappingInfo.Item.Filename = entrypointMappingInfo.FilenameInfo.OffsetInStringTable; if (entrypointMappingInfo.BuildIdInfo != null) { AddToStringTable(entrypointMappingInfo.BuildIdInfo); entrypointMappingInfo.Item.BuildId = entrypointMappingInfo.BuildIdInfo.OffsetInStringTable; } AddToMappingsList(entrypointMappingInfo); } // Sample measurement values types/units: for (int i = 0; i < OwnerBuilder.SampleValueTypes.Count; i++) { PProfInfo.ValueType sampleValueTypeInfo = OwnerBuilder.SampleValueTypeInfos[i]; AddToStringTable(sampleValueTypeInfo.TypeInfo); AddToStringTable(sampleValueTypeInfo.UnitInfo); _profile.SampleType.Add(new PProfProto.ValueType() { Type = sampleValueTypeInfo.TypeInfo.OffsetInStringTable, Unit = sampleValueTypeInfo.UnitInfo.OffsetInStringTable }); } // Drop frames RegEx: if (!string.IsNullOrWhiteSpace(OwnerBuilder.DropFramesRegExpInfo?.Item)) { AddToStringTable(OwnerBuilder.DropFramesRegExpInfo); _profile.DropFrames = OwnerBuilder.DropFramesRegExpInfo.OffsetInStringTable; } // Keep frames RegEx: if (!string.IsNullOrWhiteSpace(OwnerBuilder.KeepFramesRegExpInfo?.Item)) { AddToStringTable(OwnerBuilder.KeepFramesRegExpInfo); _profile.DropFrames = OwnerBuilder.KeepFramesRegExpInfo.OffsetInStringTable; } // Period measurement type/unit: if (OwnerBuilder.PeriodTypeInfo.HasNonDefaultValues) { AddToStringTable(OwnerBuilder.PeriodTypeInfo.TypeInfo); AddToStringTable(OwnerBuilder.PeriodTypeInfo.UnitInfo); _profile.PeriodType = new PProfProto.ValueType() { Type = OwnerBuilder.PeriodTypeInfo.TypeInfo.OffsetInStringTable, Unit = OwnerBuilder.PeriodTypeInfo.UnitInfo.OffsetInStringTable }; _profile.Period = _period; } // Default sample type (not sure what DefaultSampleType is for; not supported for now): _profile.DefaultSampleType = ProtoConstants.NumericValue.UnsetInt64; }
public Function(PProfProto.Function item, PProfInfo.String nameInfo) : this(item, nameInfo, systemNameInfo : null, filenameInfo : null) { }
public Mapping(PProfProto.Mapping item, PProfInfo.String filenameInfo) : this(item, filenameInfo, buildIdInfo : null) { }
public PProfItemCache() { _emptyStringInfo = new PProfInfo.String(string.Empty); _strings.Add(string.Empty, _emptyStringInfo); }