Commit fa1fbc8b authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[mjsunit][tools] Add processor.mjs test

Add simple log file test with processor.mjs, mostly focusing on parsing
the log file correctly.

Change-Id: Ie8db569b65ecd526ef4474a64d4019f00707d159
Bug: v8:10668
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2484515
Commit-Queue: Dan Elphick <delphick@chromium.org>
Auto-Submit: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarDan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70806}
parent b6ebafa2
......@@ -13,20 +13,25 @@ group("v8_mjsunit") {
data = [
"./",
"../../tools/arguments.js",
"../../tools/arguments.mjs",
"../../tools/clusterfuzz/v8_mock.js",
"../../tools/clusterfuzz/v8_mock_archs.js",
"../../tools/clusterfuzz/v8_mock_webassembly.js",
"../../tools/codemap.mjs",
"../../tools/consarray.mjs",
"../../tools/csvparser.mjs",
"../../tools/dumpcpp.mjs",
"../../tools/logreader.mjs",
"../../tools/arguments.mjs",
"../../tools/profile.mjs",
"../../tools/profile_view.mjs",
"../../tools/splaytree.mjs",
"../../tools/tickprocessor.mjs",
"../../tools/system-analyzer/helper.mjs",
"../../tools/system-analyzer/log/deopt.mjs",
"../../tools/system-analyzer/log/ic.mjs",
"../../tools/system-analyzer/log/log.mjs",
"../../tools/system-analyzer/log/map.mjs",
"../../tools/system-analyzer/processor.mjs",
"../../tools/system-analyzer/timeline.mjs",
"../../tools/dumpcpp.mjs",
"../../tools/tickprocessor.mjs",
]
}
// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --logfile='+' --log --trace-maps --trace-ic --log-code
// Flags: --log-function-events --no-stress-opt
import { Processor } from "../../../tools/system-analyzer/processor.mjs";
// log code start
function doWork() {
let array = [];
for (let i = 0; i < 500; i++) {
doWorkStep(i, array);
}
let sum = 0;
for (let i = 0; i < 500; i++) {
sum += array[i]["property" + i];
}
return sum;
}
function doWorkStep(i, array) {
const obj = {
["property" + i]: i,
};
array.push(obj);
obj.custom1 = 1;
obj.custom2 = 2;
}
const result = doWork();
// log code end
const logString = d8.log.getAndStop();
const processor = new Processor();
processor.processString(logString);
const maps = processor.mapTimeline;
const ics = processor.icTimeline;
const scripts = processor.scripts;
(function testResults() {
assertEquals(result, 124750);
assertTrue(maps.length > 0);
assertTrue(ics.length > 0);
assertTrue(scripts.length > 0);
})();
(function testIcKeys() {
const keys = new Set();
ics.forEach(ic => keys.add(ic.key));
assertTrue(keys.has("custom1"));
assertTrue(keys.has("custom2"));
assertTrue(keys.has("push"));
})();
......@@ -91,6 +91,10 @@ class Timeline {
return this._values.length;
}
get length() {
return this._values.length;
}
first() {
return this._values[0];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment