update test console display formatting

This commit is contained in:
Leon Chen
2016-08-26 23:36:12 -04:00
parent 9b07e511bf
commit 80fc5ddb5e
2 changed files with 33 additions and 14 deletions
+26 -13
View File
@@ -33,7 +33,8 @@ describe('core layer: Merge', function () {
let t1b = new KerasJS.Tensor(TEST_DATA[key].input.data, TEST_DATA[key].input.shape)
t1a = testLayer1a.call(t1a)
t1b = testLayer1b.call(t1b)
console.log('%cin', styles.h4, stringifyCondensed([t1a.tensor, t1b.tensor]))
console.log('%cin', styles.h4, stringifyCondensed(t1a.tensor))
console.log('%cin', styles.h4, stringifyCondensed(t1b.tensor))
const startTime = performance.now()
let t2 = testLayer2.call([t1a, t1b])
const endTime = performance.now()
@@ -67,7 +68,8 @@ describe('core layer: Merge', function () {
let t1b = new KerasJS.Tensor(TEST_DATA[key].input.data, TEST_DATA[key].input.shape)
t1a = testLayer1a.call(t1a)
t1b = testLayer1b.call(t1b)
console.log('%cin', styles.h4, stringifyCondensed([t1a.tensor, t1b.tensor]))
console.log('%cin', styles.h4, stringifyCondensed(t1a.tensor))
console.log('%cin', styles.h4, stringifyCondensed(t1b.tensor))
const startTime = performance.now()
let t2 = testLayer2.call([t1a, t1b])
const endTime = performance.now()
@@ -101,7 +103,8 @@ describe('core layer: Merge', function () {
let t1b = new KerasJS.Tensor(TEST_DATA[key].input.data, TEST_DATA[key].input.shape)
t1a = testLayer1a.call(t1a)
t1b = testLayer1b.call(t1b)
console.log('%cin', styles.h4, stringifyCondensed([t1a.tensor, t1b.tensor]))
console.log('%cin', styles.h4, stringifyCondensed(t1a.tensor))
console.log('%cin', styles.h4, stringifyCondensed(t1b.tensor))
const startTime = performance.now()
let t2 = testLayer2.call([t1a, t1b])
const endTime = performance.now()
@@ -135,7 +138,8 @@ describe('core layer: Merge', function () {
let t1b = new KerasJS.Tensor(TEST_DATA[key].input.data, TEST_DATA[key].input.shape)
t1a = testLayer1a.call(t1a)
t1b = testLayer1b.call(t1b)
console.log('%cin', styles.h4, stringifyCondensed([t1a.tensor, t1b.tensor]))
console.log('%cin', styles.h4, stringifyCondensed(t1a.tensor))
console.log('%cin', styles.h4, stringifyCondensed(t1b.tensor))
const startTime = performance.now()
let t2 = testLayer2.call([t1a, t1b])
const endTime = performance.now()
@@ -169,7 +173,8 @@ describe('core layer: Merge', function () {
let tb = new KerasJS.Tensor(TEST_DATA[key].input.data, TEST_DATA[key].input.shape)
ta = testLayer1a.call(ta)
tb = testLayer1b.call(tb)
console.log('%cin', styles.h4, stringifyCondensed([ta.tensor, tb.tensor]))
console.log('%cin', styles.h4, stringifyCondensed(ta.tensor))
console.log('%cin', styles.h4, stringifyCondensed(tb.tensor))
const startTime = performance.now()
let t = testLayer2.call([ta, tb])
const endTime = performance.now()
@@ -197,7 +202,8 @@ describe('core layer: Merge', function () {
ta = testLayer2a.call(ta)
tb = testLayer1b.call(tb)
tb = testLayer2b.call(tb)
console.log('%cin', styles.h4, stringifyCondensed([ta.tensor, tb.tensor]))
console.log('%cin', styles.h4, stringifyCondensed(ta.tensor))
console.log('%cin', styles.h4, stringifyCondensed(tb.tensor))
const startTime = performance.now()
let t = testLayer3.call([ta, tb])
const endTime = performance.now()
@@ -225,7 +231,8 @@ describe('core layer: Merge', function () {
ta = testLayer2a.call(ta)
tb = testLayer1b.call(tb)
tb = testLayer2b.call(tb)
console.log('%cin', styles.h4, stringifyCondensed([ta.tensor, tb.tensor]))
console.log('%cin', styles.h4, stringifyCondensed(ta.tensor))
console.log('%cin', styles.h4, stringifyCondensed(tb.tensor))
const startTime = performance.now()
let t = testLayer3.call([ta, tb])
const endTime = performance.now()
@@ -253,7 +260,8 @@ describe('core layer: Merge', function () {
ta = testLayer2a.call(ta)
tb = testLayer1b.call(tb)
tb = testLayer2b.call(tb)
console.log('%cin', styles.h4, stringifyCondensed([ta.tensor, tb.tensor]))
console.log('%cin', styles.h4, stringifyCondensed(ta.tensor))
console.log('%cin', styles.h4, stringifyCondensed(tb.tensor))
const startTime = performance.now()
let t = testLayer3.call([ta, tb])
const endTime = performance.now()
@@ -281,7 +289,8 @@ describe('core layer: Merge', function () {
ta = testLayer2a.call(ta)
tb = testLayer1b.call(tb)
tb = testLayer2b.call(tb)
console.log('%cin', styles.h4, stringifyCondensed([ta.tensor, tb.tensor]))
console.log('%cin', styles.h4, stringifyCondensed(ta.tensor))
console.log('%cin', styles.h4, stringifyCondensed(tb.tensor))
const startTime = performance.now()
let t = testLayer3.call([ta, tb])
const endTime = performance.now()
@@ -319,7 +328,8 @@ describe('core layer: Merge', function () {
ta = testLayer2a.call(ta)
tb = testLayer1b.call(tb)
tb = testLayer2b.call(tb)
console.log('%cin', styles.h4, stringifyCondensed([ta.tensor, tb.tensor]))
console.log('%cin', styles.h4, stringifyCondensed(ta.tensor))
console.log('%cin', styles.h4, stringifyCondensed(tb.tensor))
const startTime = performance.now()
let t = testLayer3.call([ta, tb])
const endTime = performance.now()
@@ -347,7 +357,8 @@ describe('core layer: Merge', function () {
ta = testLayer2a.call(ta)
tb = testLayer1b.call(tb)
tb = testLayer2b.call(tb)
console.log('%cin', styles.h4, stringifyCondensed([ta.tensor, tb.tensor]))
console.log('%cin', styles.h4, stringifyCondensed(ta.tensor))
console.log('%cin', styles.h4, stringifyCondensed(tb.tensor))
const startTime = performance.now()
let t = testLayer3.call([ta, tb])
const endTime = performance.now()
@@ -385,7 +396,8 @@ describe('core layer: Merge', function () {
ta = testLayer2a.call(ta)
tb = testLayer1b.call(tb)
tb = testLayer2b.call(tb)
console.log('%cin', styles.h4, stringifyCondensed([ta.tensor, tb.tensor]))
console.log('%cin', styles.h4, stringifyCondensed(ta.tensor))
console.log('%cin', styles.h4, stringifyCondensed(tb.tensor))
const startTime = performance.now()
let t = testLayer3.call([ta, tb])
const endTime = performance.now()
@@ -413,7 +425,8 @@ describe('core layer: Merge', function () {
ta = testLayer2a.call(ta)
tb = testLayer1b.call(tb)
tb = testLayer2b.call(tb)
console.log('%cin', styles.h4, stringifyCondensed([ta.tensor, tb.tensor]))
console.log('%cin', styles.h4, stringifyCondensed(ta.tensor))
console.log('%cin', styles.h4, stringifyCondensed(tb.tensor))
const startTime = performance.now()
let t = testLayer3.call([ta, tb])
const endTime = performance.now()
+7 -1
View File
@@ -14,7 +14,13 @@
}
function stringifyCondensed (obj) {
return JSON.stringify(obj, function (key, val) {
var newObj = Object.assign({}, obj)
if (newObj.data.length > 10) {
newObj.data = Array.from(newObj.data.subarray(0, 10)).concat(['...'])
} else {
newObj.data = Array.from(newObj.data)
}
return JSON.stringify(newObj, function (key, val) {
return val.toFixed ? Number(val.toFixed(3)) : val
})
}