Ejemplo n.º 1
0
        internal static Task <PipRuntimeTimeTable> LoadAsync(Stream fileStream)
        {
            return(ExceptionUtilities.HandleRecoverableIOExceptionAsync(
                       async() =>
            {
                int size = await ReadFileFormatMarkerAsync(fileStream);
                var table = new PipRuntimeTimeTable(LoggingContext);

                using (BuildXLReader reader = new BuildXLReader(false, fileStream, true))
                {
                    for (int i = 0; i < size; ++i)
                    {
                        long semiStableHash = reader.ReadInt64();
                        PipHistoricPerfData historicData;
                        if (PipHistoricPerfData.Deserialize(reader, out historicData))
                        {
                            if (!table.m_runtimeData.TryAdd(semiStableHash, historicData))
                            {
                                throw new BuildXLException("Corrupted file has duplicate records");
                            }
                        }
                    }
                }

                if (fileStream.Position != fileStream.Length)
                {
                    throw new BuildXLException("Corrupted file has excess bytes");
                }

                return table;
            },
                       ex => { throw new BuildXLException("Reading of file failed", ex); }));
        }
Ejemplo n.º 2
0
        internal static PipRuntimeTimeTable Load(Stream stream)
        {
            return ExceptionUtilities.HandleRecoverableIOException(
                () =>
                {
                    Analysis.IgnoreResult(FileEnvelope.ReadHeader(stream));
                    using (BuildXLReader reader = new BuildXLReader(debug: false, stream: stream, leaveOpen: true))
                    {
                        int size = reader.ReadInt32();
                        var table = new PipRuntimeTimeTable(initialCapacity: size);

                        for (int i = 0; i < size; ++i)
                        {
                            long semiStableHash = reader.ReadInt64();
                            PipHistoricPerfData historicData;
                            if (PipHistoricPerfData.Deserialize(reader, out historicData))
                            {
                                if (!table.m_runtimeData.TryAdd(semiStableHash, historicData))
                                {
                                    throw new BuildXLException("Corrupted file has duplicate records");
                                }
                            }
                        }

                        return table;
                    }
                },
                ex => { throw new BuildXLException("Reading of file failed", ex); });
        }