electron/default_app/default_app.js

237 lines
5.4 KiB
JavaScript
Raw Normal View History

2016-07-27 16:24:58 +00:00
const {app, BrowserWindow, contentTracing} = require('electron')
2016-07-06 18:47:21 +00:00
const path = require('path')
2016-07-27 16:24:58 +00:00
const options = {
categoryFilter: '*',
traceOptions: 'record-until-full,enable-sampling'
};
2016-07-22 11:55:58 +00:00
let mainWindow1 = null
let mainWindow2 = null
let mainWindow3 = null
let mainWindow4 = null
let mainWindow5 = null
let mainWindow6 = null
let mainWindow7 = null
let mainWindow8 = null
2016-07-27 23:58:23 +00:00
app.commandLine.appendSwitch('--disable-gpu');
app.commandLine.appendSwitch('--disable-gpu-compositing');
// Quit when all windows are closed.
app.on('window-all-closed', () => {
app.quit()
})
exports.load = (appUrl) => {
app.on('ready', () => {
2016-07-22 11:55:58 +00:00
mainWindow1 = new BrowserWindow({
width: 800,
height: 600,
autoHideMenuBar: true,
2016-04-26 16:25:46 +00:00
backgroundColor: '#FFFFFF',
2016-07-22 11:55:58 +00:00
useContentSize: true,
webPreferences: {
2016-07-31 15:10:53 +00:00
// offscreen: true,
2016-07-22 11:55:58 +00:00
nodeIntegration: false
}
})
mainWindow1.loadURL(appUrl)
mainWindow1.focus()
var start1, end1
start1 = +new Date();
mainWindow1.webContents.on('paint', (e, rect, w, h, data) => {
end1 = +new Date();
const d = end1 - start1
2016-07-27 17:19:53 +00:00
console.log(`browser #1: ${d < 10 ? ` ${d}` : d} ms`)
2016-07-22 11:55:58 +00:00
start1 = end1
})
2016-07-29 12:50:27 +00:00
2016-07-27 16:24:58 +00:00
/*contentTracing.startRecording(options, () => {
console.log('Tracing started');
2016-07-22 11:55:58 +00:00
2016-07-27 16:24:58 +00:00
setTimeout(() => {
contentTracing.stopRecording('', (path) => {
console.log('Tracing data recorded to ' + path);
});
}, 5000);
});*/
mainWindow2 = new BrowserWindow({
width: 800,
height: 600,
autoHideMenuBar: true,
backgroundColor: '#FFFFFF',
useContentSize: true,
webPreferences: {
nodeIntegration: false
}
})
mainWindow2.loadURL("http://4danatomy.com")
2016-07-27 16:24:58 +00:00
mainWindow2.focus()
2016-07-29 12:50:27 +00:00
2016-07-27 16:24:58 +00:00
var start2, end2
start2 = +new Date();
mainWindow2.webContents.on('paint', (e, rect, w, h, data) => {
end2 = +new Date();
2016-07-29 12:50:27 +00:00
2016-07-27 16:24:58 +00:00
const d = end2 - start2
2016-07-27 17:19:53 +00:00
console.log(`browser #2: ${d < 10 ? ` ${d}` : d} ms`)
2016-07-29 12:50:27 +00:00
2016-07-27 16:24:58 +00:00
start2 = end2
2016-07-31 15:10:53 +00:00
})
2016-07-29 12:50:27 +00:00
mainWindow3 = new BrowserWindow({
width: 800,
height: 600,
autoHideMenuBar: true,
backgroundColor: '#FFFFFF',
useContentSize: true,
webPreferences: {
offscreen: true,
nodeIntegration: false
}
})
mainWindow3.loadURL(appUrl)
mainWindow3.focus()
2016-07-29 12:50:27 +00:00
var start3, end3
start3 = +new Date();
mainWindow3.webContents.on('paint', (e, rect, w, h, data) => {
end3 = +new Date();
2016-07-29 12:50:27 +00:00
const d = end3 - start3
console.log(`browser #3: ${d < 10 ? ` ${d}` : d} ms`)
2016-07-29 12:50:27 +00:00
start3 = end3
})
2016-07-29 12:50:27 +00:00
mainWindow4 = new BrowserWindow({
width: 800,
height: 600,
autoHideMenuBar: true,
backgroundColor: '#FFFFFF',
useContentSize: true,
webPreferences: {
offscreen: true,
nodeIntegration: false
}
})
mainWindow4.loadURL(appUrl)
mainWindow4.focus()
2016-07-29 12:50:27 +00:00
var start4, end4
start4 = +new Date();
mainWindow4.webContents.on('paint', (e, rect, w, h, data) => {
end4 = +new Date();
2016-07-29 12:50:27 +00:00
const d = end4 - start4
console.log(`browser #4: ${d < 10 ? ` ${d}` : d} ms`)
2016-07-29 12:50:27 +00:00
start4 = end4
})
2016-07-29 12:50:27 +00:00
mainWindow5 = new BrowserWindow({
width: 800,
height: 600,
autoHideMenuBar: true,
backgroundColor: '#FFFFFF',
useContentSize: true,
webPreferences: {
offscreen: true,
nodeIntegration: false
}
})
mainWindow5.loadURL(appUrl)
mainWindow5.focus()
2016-07-29 12:50:27 +00:00
var start5, end5
start5 = +new Date();
mainWindow5.webContents.on('paint', (e, rect, w, h, data) => {
end5 = +new Date();
2016-07-29 12:50:27 +00:00
const d = end5 - start5
console.log(`browser #5: ${d < 10 ? ` ${d}` : d} ms`)
2016-07-29 12:50:27 +00:00
start5 = end5
})
2016-07-29 12:50:27 +00:00
mainWindow6 = new BrowserWindow({
width: 800,
height: 600,
autoHideMenuBar: true,
backgroundColor: '#FFFFFF',
useContentSize: true,
webPreferences: {
offscreen: true,
nodeIntegration: false
}
})
mainWindow6.loadURL(appUrl)
mainWindow6.focus()
2016-07-29 12:50:27 +00:00
var start6, end6
start6 = +new Date();
mainWindow6.webContents.on('paint', (e, rect, w, h, data) => {
end6 = +new Date();
2016-07-29 12:50:27 +00:00
const d = end6 - start6
console.log(`browser #6: ${d < 10 ? ` ${d}` : d} ms`)
2016-07-29 12:50:27 +00:00
start6 = end6
})
2016-07-29 12:50:27 +00:00
mainWindow7 = new BrowserWindow({
width: 800,
height: 600,
autoHideMenuBar: true,
backgroundColor: '#FFFFFF',
useContentSize: true,
webPreferences: {
offscreen: true,
nodeIntegration: false
}
})
mainWindow7.loadURL(appUrl)
mainWindow7.focus()
2016-07-29 12:50:27 +00:00
var start7, end7
start7 = +new Date();
mainWindow7.webContents.on('paint', (e, rect, w, h, data) => {
end7 = +new Date();
2016-07-29 12:50:27 +00:00
const d = end7 - start7
console.log(`browser #7: ${d < 10 ? ` ${d}` : d} ms`)
2016-07-29 12:50:27 +00:00
start7 = end7
})
2016-07-29 12:50:27 +00:00
mainWindow8 = new BrowserWindow({
width: 800,
height: 600,
autoHideMenuBar: true,
backgroundColor: '#FFFFFF',
useContentSize: true,
webPreferences: {
offscreen: true,
nodeIntegration: false
}
})
mainWindow8.loadURL(appUrl)
mainWindow8.focus()
2016-07-29 12:50:27 +00:00
var start8, end8
start8 = +new Date();
mainWindow8.webContents.on('paint', (e, rect, w, h, data) => {
end8 = +new Date();
2016-07-29 12:50:27 +00:00
const d = end8 - start8
console.log(`browser #8: ${d < 10 ? ` ${d}` : d} ms`)
2016-07-29 12:50:27 +00:00
start8 = end8
})
})
}