Skip to content

Commit 0c98e6f

Browse files
committed
Merge pull request #5 from zz85/faster_scanning
Faster scanning
2 parents e619e14 + f56c9b3 commit 0c98e6f

12 files changed

Lines changed: 735 additions & 503 deletions

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,18 @@ Future Enhancements
2424
- moar!!
2525
- let me know what you think
2626

27+
Whats New
28+
==
29+
30+
2.0.0
31+
- Major speed up scanning directories. About 10x from version 1, and almost as fast or faster than du.
32+
- Runs disk scanning as a separate headless renderer process
33+
- Json is passed back via IPC
34+
- Remove Async npm dependency
35+
2736
Known Issues
2837
==
29-
- Electron may freeze when scanning really really large directories
38+
- UI may freeze momentary loading large data sets
3039

3140
Development
3241
==

css/breadcrumb.css

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,14 @@
3939

4040
/*hover/active styles*/
4141
.breadcrumb a.active, .breadcrumb a:hover{
42-
background: #333;
43-
background: linear-gradient(#333, #000);
42+
/*background: #333;
43+
background: linear-gradient(#333, #000);*/
44+
opacity: 0.8;
4445
}
4546
.breadcrumb a.active:after, .breadcrumb a:hover:after {
46-
background: #333;
47-
background: linear-gradient(135deg, #333, #000);
47+
/*background: #333;
48+
background: linear-gradient(135deg, #333, #000);*/
49+
opacity: 0.8;
4850
}
4951

5052
/*adding the arrows for the breadcrumbs using rotated pseudo elements*/
@@ -108,5 +110,5 @@
108110
}
109111
.flat a:hover, .flat a.active,
110112
.flat a:hover:after, .flat a.active:after{
111-
background: #9EEB62;
113+
/*background: #9EEB62;*/
112114
}

css/style.css

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
path {
2+
stroke: #fff;
3+
fill-rule: evenodd;
4+
}
5+
6+
7+
circle,
8+
path {
9+
10+
}
11+
12+
circle {
13+
fill: none;
14+
pointer-events: all;
15+
}
16+
17+
circle:hover {
18+
fill: #999;
19+
opacity: 0.5;
20+
}
21+
22+
#core:hover {
23+
opacity: 0.5;
24+
cursor: pointer;
25+
}
26+
27+
28+
/* treemap */
29+
30+
rect {
31+
fill: none;
32+
pointer-events: all;
33+
}
34+
35+
pre {
36+
font-size: 18px;
37+
}
38+
39+
line {
40+
stroke: #000;
41+
stroke-width: 1.5px;
42+
}
43+
44+
.string, .regexp {
45+
color: #f39;
46+
}
47+
48+
.keyword {
49+
color: #00c;
50+
}
51+
52+
.comment {
53+
color: #777;
54+
font-style: oblique;
55+
}
56+
57+
.number {
58+
color: #369;
59+
}
60+
61+
.class, .special {
62+
color: #1181B8;
63+
}
64+
65+
/* end treemap */
66+
67+
body {
68+
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
69+
margin: auto;
70+
position: relative;
71+
overflow: none;
72+
}
73+
74+
.cell > rect:hover {
75+
fill: yellow;
76+
}
77+
78+
/* legend */
79+
80+
#explanation {
81+
font-family: Avenir, Arial, Helvetica, sans-serif;
82+
position: absolute;
83+
/*top: 260px;
84+
left: 305px*/;
85+
width: 140px;
86+
height: 140px;
87+
margin: auto;
88+
top: 0;
89+
left: 0;
90+
right: 0;
91+
bottom: 0;
92+
text-align: center;
93+
color: #333;
94+
z-index: -1;
95+
/*z-index: -1;*/
96+
}
97+
98+
#core_top {
99+
/*font-size: 2.5em;*/
100+
}
101+
102+
#core_center {
103+
font-size: 2em;
104+
}
105+
106+
107+
#legend {
108+
text-align:center;
109+
font-family: Avenir, Arial, Helvetica, sans-serif;
110+
padding-top:20px;
111+
position: absolute;
112+
left: 0;
113+
right: 0;
114+
top: 40px;
115+
z-index: 50;
116+
}
117+
118+
#legend h2 {
119+
font-size:1.2em;
120+
font-style:inherit;
121+
margin: 0;
122+
padding: 0;
123+
}
124+
#legend p {
125+
font-size:.9em;
126+
margin: 0;
127+
padding: 0;
128+
text-transform: uppercase;
129+
font-variant:small-caps;
130+
}
131+
132+
#loading {
133+
left: 0;
134+
right: 0;
135+
top: 0;
136+
bottom: 0;
137+
position: fixed;
138+
display: inline-block;
139+
margin: auto;
140+
z-index: 10;
141+
width: 100px;
142+
height: 100px;
143+
display: none;
144+
}
145+
146+
.hmm {
147+
opacity: 0.8;
148+
cursor: pointer;
149+
}
150+
151+
.hmm:hover {
152+
stroke: #999;
153+
stroke-width: 2px;
154+
opacity: 1;
155+
}
156+
157+
.svg-container {
158+
display: inline-block;
159+
position: relative;
160+
width: 100%;
161+
/*padding-bottom: 100%;*/ /* aspect ratio */
162+
vertical-align: top;
163+
overflow: hidden;
164+
}
165+
166+
.svg-content-responsive {
167+
display: inline-block;
168+
position: absolute;
169+
top: 10px;
170+
left: 0;
171+
}
172+
173+
#sequence {
174+
position: absolute;
175+
bottom: 0;
176+
left: 0;
177+
z-index: 100;
178+
/*width: 600px;
179+
height: 70px;*/
180+
}
181+
182+
183+
#chart {
184+
position: relative;
185+
}
186+
187+
#chart path {
188+
stroke: #fff;
189+
}

headless.html

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<html>
2+
<head>
3+
<title>DU headless</title>
4+
</head>
5+
<body>
6+
<script>
7+
8+
'use strict';
9+
10+
const path = require('path')
11+
const ipc = require('ipc')
12+
const du = require('./js/du')
13+
14+
const ipc_name = 'du'
15+
ipc.send('register', ipc_name)
16+
17+
ipc.on('ready', function() {
18+
console.log('all is ready')
19+
go();
20+
})
21+
22+
ipc.on('broadcast', function(arg) {
23+
console.log('[' + ipc_name + '] broadcast', arg)
24+
})
25+
26+
ipc.on('message', function(arg) {
27+
console.log('[' + ipc_name + '] message', arg)
28+
})
29+
30+
function go() {
31+
32+
let target = '../../..'
33+
var INCREMENTAL_INTERVAL = 30000
34+
35+
let checker
36+
let json = {}
37+
console.time('async2')
38+
39+
function complete(counter) {
40+
// console.log("Scan completed", counter, "files");
41+
console.timeEnd('async2')
42+
clearTimeout(checker)
43+
44+
console.log(json);
45+
46+
// cache
47+
// console.time('write')
48+
// fs.writeFileSync('test.json', JSON.stringify(json))
49+
// console.timeEnd('write')
50+
51+
ipc.send('call', 'viz', 'complete', json)
52+
};
53+
54+
function refresh() {
55+
clearTimeout(checker)
56+
console.log('scanning...');
57+
58+
ipc.send('call', 'viz', 'refresh', json)
59+
checker = setTimeout(refresh, INCREMENTAL_INTERVAL)
60+
}
61+
62+
function progress(path, name) {
63+
ipc.send('call', 'viz', 'progress', path, name)
64+
}
65+
66+
target = path.resolve(target)
67+
console.log('Scanning target', target)
68+
69+
// yay
70+
du({
71+
parent: target,
72+
node: json,
73+
onprogress: progress,
74+
// onrefresh: refresh
75+
}, complete)
76+
77+
setTimeout(refresh, 5000)
78+
}
79+
80+
81+
// // d3.json("flare.json", onJson);
82+
// // for testing purposes only
83+
// // json = fs.readFileSync('user.json', { encoding: 'utf-8'})
84+
// // loading.style.display = 'none'
85+
// // onJson(null, JSON.parse(json).children[10])
86+
// // onJson(null, JSON.parse(json))
87+
// })
88+
89+
90+
</script>
91+
<script>
92+
// // redirect log to stdout
93+
// console.log = require('console').log
94+
// // redirect errors to stderr
95+
// window.addEventListener('error', function (e) {
96+
// e.preventDefault()
97+
// require('console').error(e.error.stack || 'Uncaught ' + e.error)
98+
// })
99+
100+
// ipc.on('args', function (args) {
101+
// console.log('yoz i got something!!!')
102+
// // var app
103+
// // if (path.isAbsolute(args[2])) {
104+
// // app = require(args[2])
105+
// // } else {
106+
// // app = require(path.join(process.cwd(), args[2]))
107+
// // }
108+
// // if (typeof app === 'function') app(args.slice(2))
109+
// })
110+
</script>
111+
</body>
112+
</html>

0 commit comments

Comments
 (0)