Ejemplo n.º 1
0
        public PProfBuilder()
        {
            _periodTypeInfo = new PProfInfo.ValueType(new PProfSampleValueType(type: null, unit: null), this);

            this.SymbolMonikersConfig = new SymbolMonikersConfigSettings(this);
            this.SampleValueTypes     = new PProfSampleValueType[0];
            this.SampleValueTypeInfos = new PProfInfo.ValueType[0];
            this.SampleValuesUnset    = new long[0];
        }
Ejemplo n.º 2
0
        public void SetSampleValueTypes(IEnumerable <PProfSampleValueType> valueTypes)
        {
            if (_buildState.Session != null && _buildState.Session.SamplesCount > 0)
            {
                throw new InvalidOperationException($"Cannot invoke {nameof(SetSampleValueTypes)}(..) when there is an active "
                                                    + $" {nameof(PProfBuildSession)} and {_buildState.Session.SamplesCount} samples have been added to that session.");
            }

            if (valueTypes == null)
            {
                SampleValueTypes     = new PProfSampleValueType[0];
                SampleValueTypeInfos = new PProfInfo.ValueType[0];
                SampleValuesUnset    = new long[0];
                return;
            }

            int valueTypesCount;

            if (valueTypes is ICollection <PProfSampleValueType> valueTypesCollection)
            {
                valueTypesCount = valueTypesCollection.Count;
            }
            else if (valueTypes is IReadOnlyCollection <PProfSampleValueType> valueTypesROCollection)
            {
                valueTypesCount = valueTypesROCollection.Count;
            }
            else
            {
                valueTypesCount = valueTypes.Count();
            }

            var newSampleValueTypes     = new PProfSampleValueType[valueTypesCount];
            var newSampleValueTypeInfos = new PProfInfo.ValueType[valueTypesCount];
            var newSampleValuesUnset    = new long[valueTypesCount];

            int i = 0;

            foreach (PProfSampleValueType vt in valueTypes)
            {
                newSampleValueTypes[i]     = vt;
                newSampleValueTypeInfos[i] = new PProfInfo.ValueType(vt, this);
                newSampleValuesUnset[i]    = ProtoConstants.NumericValue.UnsetInt64;
                i++;
            }

            SampleValueTypes     = newSampleValueTypes;
            SampleValueTypeInfos = newSampleValueTypeInfos;
            SampleValuesUnset    = newSampleValuesUnset;
        }
Ejemplo n.º 3
0
        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;
        }