]>
git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/opentelemetry-cpp/third_party/prometheus-cpp/3rdparty/civetweb/src/third_party/duktape-1.8.0/examples/eventloop/curses-timers.js
2 * Test using timers and intervals with curses.
5 if (typeof Ncurses
!== 'object') {
6 throw new Error('Ncurses required');
9 function fillScreen(ch
) {
13 size
= Ncurses
.getmaxyx();
17 for (i
= 0; i
< h
; i
++) {
18 for (j
= 0; j
< w
; j
++) {
19 Ncurses
.mvprintw(i
, j
, ch
);
31 size
= Ncurses
.getmaxyx();
37 setInterval(function () {
38 Ncurses
.mvprintw(1, 4, new Date().toISOString());
42 function addCounter(row
, index
, interval
) {
44 setInterval(function () {
46 Ncurses
.mvprintw(row
, 4, '' + Date
.now() + ' ' + counters
[index
]);
51 function addRandomChar(row
, col
, interval
) {
52 setTimeout(function () {
53 Ncurses
.mvprintw(row
, col
, String
.fromCharCode(Math
.random() * 64 + 0x20));
58 for (i
= 0; i
< h
- 5; i
++) {
59 addCounter(3 + i
, i
, 363 * i
+ 400);
62 /* Here the inserts take a lot of time because the underlying timer manager
63 * data structure has O(n) insertion performance.
65 for (i
= 0; i
< h
- 5; i
++) {
66 for (j
= 0; j
< w
- 50; j
++) {
67 // Math.exp(0)...Math.exp(8) is an uneven distribution between 1...~2980.
68 addRandomChar(3 + i
, 28 + j
, 58000 - Math
.exp(Math
.random() * 8) * 20);
72 setTimeout(function () {
75 requestEventLoopExit();