mirror of
https://github.com/danbulant/node-x11
synced 2026-05-22 22:09:14 +00:00
added 'lost in merge' wndwrap; t61/ubuntu benchmarks
This commit is contained in:
parent
8347e51fbf
commit
148ba49cde
4 changed files with 136 additions and 12 deletions
|
|
@ -1,15 +1,21 @@
|
|||
// WinServ2008R2 64bit, Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz + Xming 6.9.0.31
|
||||
// WinServ2008R2 64bit, Intel(R) Core(TM) i7 CPU 870 @2.93GHz, Xming 6.9.0.31
|
||||
// 0.4.3/cygwin 32bit: 12000 +/-1000 InternAtom/sec
|
||||
// 0.5.1/win32 : 12000 +/-1000
|
||||
|
||||
// Ubuntu 11.04 32bit, Intel(R) Core(TM)2 Duo CPU T7250 @2.00GHz, XOrg 1:7.6+4ubuntu3.1
|
||||
// 0.4.9pre: 23300 +/-200
|
||||
|
||||
|
||||
var x11 = require('../lib/x11');
|
||||
|
||||
var xclient = x11.createClient();
|
||||
var counter = 0;
|
||||
var t = +new Date();
|
||||
var t0 = t;
|
||||
var num = 10000;
|
||||
var num = 100000;
|
||||
xclient.on('connect', function(display) {
|
||||
console.log(display);
|
||||
process.exit(0);
|
||||
var X = this;
|
||||
for (var i=0; i < num; ++i)
|
||||
{
|
||||
|
|
@ -22,16 +28,16 @@ xclient.on('connect', function(display) {
|
|||
t = t1;
|
||||
}
|
||||
//console.log('atom %d saved on server', atomId);
|
||||
/*
|
||||
if ((counter % 1000) == 0)
|
||||
|
||||
if ((counter % 10000) == 0)
|
||||
{
|
||||
var t1 = +new Date();
|
||||
console.log('received 1000 (up to %d) atom ids in %d ms', counter, t1 - t);
|
||||
console.log('received 10000 (up to %d) atom ids in %d ms', counter, t1 - t);
|
||||
t = t1;
|
||||
}
|
||||
*/
|
||||
|
||||
counter++;
|
||||
if (counter == num)
|
||||
if (counter == (num-1))
|
||||
{
|
||||
var t1 = +new Date();
|
||||
var delta = t1 - t0;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,13 @@
|
|||
// test results:
|
||||
|
||||
// WinServ2008R2, Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz + Xming 6.9.0.31
|
||||
//
|
||||
// 0.4.3/cygwin 32bit : 8500 +/- 2000 InternAtom/sec
|
||||
// 0.5.1/win32 : N/A
|
||||
//
|
||||
// Ubuntu 11.04 32bit, Intel(R) Core(TM)2 Duo CPU T7250 @2.00GHz, XOrg 1:7.6+4ubuntu3.1
|
||||
// 0.4.9pre: 16700 +/-300
|
||||
|
||||
|
||||
var x11 = require('../lib/x11');
|
||||
|
||||
|
|
@ -10,8 +15,6 @@ var xclient = x11.createClient();
|
|||
var reqcounter = 0;
|
||||
var rescounter = 0;
|
||||
|
||||
var t = +new Date();
|
||||
var t0 = t;
|
||||
var num = 400000;
|
||||
var X;
|
||||
|
||||
|
|
@ -25,9 +28,16 @@ function benchmarkAtoms()
|
|||
X.InternAtom(false, 'test ' + reqcounter, function(atomId) {
|
||||
rescounter++;
|
||||
//console.log('%d received', rescounter);
|
||||
//if ( (rescounter % 1000) == 0)
|
||||
// console.log(reqcounter - rescounter);
|
||||
if (rescounter == num)
|
||||
if ( (rescounter % 10000) == 0)
|
||||
{
|
||||
var t2 = X.t1;
|
||||
X.t1 = +new Date();
|
||||
var delta = X.t1 - t2;
|
||||
console.log(reqcounter - rescounter);
|
||||
console.log('reqs/msec: ' + 10000/delta);
|
||||
console.log('msec per req: ' + delta/10000);
|
||||
}
|
||||
if (rescounter == (num-2))
|
||||
{
|
||||
var t1 = +new Date();
|
||||
var delta = t1 - t0;
|
||||
|
|
@ -48,5 +58,6 @@ function benchmarkAtoms()
|
|||
|
||||
xclient.on('connect', function(display) {
|
||||
X = this;
|
||||
X.t1 = +new Date();
|
||||
benchmarkAtoms();
|
||||
});
|
||||
|
|
|
|||
37
test/testwnd.js
Normal file
37
test/testwnd.js
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
var x11 = require('../lib/x11');
|
||||
var Window = require('./wndwrap');
|
||||
|
||||
var width = 700;
|
||||
var height = 500;
|
||||
|
||||
var xclient = x11.createClient();
|
||||
xclient.on('connect', function(display) {
|
||||
var white = xclient.display.screen[0].white_pixel;
|
||||
var black = xclient.display.screen[0].black_pixel;
|
||||
|
||||
var mainwnd = new Window(xclient, 0, 0, width, height, white);
|
||||
mainwnd.on('mousemove', function(ev) {
|
||||
console.log(ev.x, ev.y);
|
||||
});
|
||||
var ch = new Window(mainwnd, 10, 10, 50, 70, black);
|
||||
ch.on('mousemove', function(ev) {
|
||||
console.log(ev);
|
||||
//ch.unmap();
|
||||
//setTimeout( function() { ch.map() }, 500);
|
||||
});
|
||||
|
||||
mainwnd.map();
|
||||
/*
|
||||
for (var x = 0; x < width; x += 20) {
|
||||
for (var y = 0; y < width; y += 20) {
|
||||
// TODO: wnd.createChild() ?
|
||||
var ch = new Window(mainwnd, x + 1, y + 1, 18, 18, 0, black);
|
||||
//ch.map();
|
||||
ch.on('mousemove', function(ev) {
|
||||
ch.unmap();
|
||||
setTimeout( function() { ch.map() }, 500);
|
||||
});
|
||||
}
|
||||
}
|
||||
*/
|
||||
});
|
||||
70
test/wndwrap.js
Normal file
70
test/wndwrap.js
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
var EventEmitter = require('events').EventEmitter;
|
||||
var util = require('util'); // util.inherits
|
||||
|
||||
function Window(parent, x, y, w, h, bg)
|
||||
{
|
||||
if (parent.constructor && parent.constructor.name == 'XClient')
|
||||
{
|
||||
this.xclient = parent;
|
||||
if (!this.xclient.rootWindow)
|
||||
{
|
||||
// quick hack
|
||||
var rootWnd = {
|
||||
id: this.xclient.display.screen[0].root,
|
||||
xclient: this.xclient
|
||||
};
|
||||
rootWnd.parent = null;
|
||||
this.parent = this.xclient.rootWnd;
|
||||
this.xclient.rootWindow = rootWnd;
|
||||
}
|
||||
this.parent = this.xclient.rootWindow;
|
||||
} else {
|
||||
this.parent = parent;
|
||||
this.xclient = parent.xclient;
|
||||
}
|
||||
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.w = w;
|
||||
this.h = h;
|
||||
this.bg = bg;
|
||||
this.id = this.xclient.AllocID();
|
||||
|
||||
var borderWidth = 1;
|
||||
var _class = 1; // InputOutput
|
||||
var visual = 0; // CopyFromParent
|
||||
this.xclient.CreateWindow(
|
||||
this.id, this.parent.id, this.x, this.y, this.w, this.h,
|
||||
borderWidth, _class, visual,
|
||||
{
|
||||
backgroundPixel: this.bg,
|
||||
eventMask: 0x00000040
|
||||
}
|
||||
);
|
||||
//this.map();
|
||||
|
||||
var wnd = this;
|
||||
eventType2eventName = {
|
||||
6: 'mousemove'
|
||||
};
|
||||
|
||||
var ee = new EventEmitter();
|
||||
this.xclient.event_consumers[wnd.id] = ee;
|
||||
// TODO: do we need to have wnd as EventEmitter AND EventEmitter stored in event_consumers ?
|
||||
ee.on('event', function( ev )
|
||||
{
|
||||
wnd.emit(eventType2eventName[ev.type], ev); // convert to mousemove? (ev is already event-spacific)
|
||||
});
|
||||
// TODO: track delete events and remove wmd from consumers list
|
||||
}
|
||||
util.inherits(Window, EventEmitter);
|
||||
|
||||
Window.prototype.map = function() {
|
||||
this.xclient.MapWindow(this.id);
|
||||
}
|
||||
|
||||
Window.prototype.unmap = function() {
|
||||
this.xclient.UnmapWindow(this.id);
|
||||
}
|
||||
|
||||
module.exports = Window;
|
||||
Loading…
Reference in a new issue