Skip to content

Commit

Permalink
Merge pull request #5 from zz85/faster_scanning
Browse files Browse the repository at this point in the history
Faster scanning
  • Loading branch information
zz85 committed Oct 22, 2015
2 parents e619e14 + f56c9b3 commit 0c98e6f
Show file tree
Hide file tree
Showing 12 changed files with 735 additions and 503 deletions.
11 changes: 10 additions & 1 deletion README.md
Expand Up @@ -24,9 +24,18 @@ Future Enhancements
- moar!!
- let me know what you think

Whats New
==

2.0.0
- Major speed up scanning directories. About 10x from version 1, and almost as fast or faster than du.
- Runs disk scanning as a separate headless renderer process
- Json is passed back via IPC
- Remove Async npm dependency

Known Issues
==
- Electron may freeze when scanning really really large directories
- UI may freeze momentary loading large data sets

Development
==
Expand Down
12 changes: 7 additions & 5 deletions css/breadcrumb.css
Expand Up @@ -39,12 +39,14 @@

/*hover/active styles*/
.breadcrumb a.active, .breadcrumb a:hover{
background: #333;
background: linear-gradient(#333, #000);
/*background: #333;
background: linear-gradient(#333, #000);*/
opacity: 0.8;
}
.breadcrumb a.active:after, .breadcrumb a:hover:after {
background: #333;
background: linear-gradient(135deg, #333, #000);
/*background: #333;
background: linear-gradient(135deg, #333, #000);*/
opacity: 0.8;
}

/*adding the arrows for the breadcrumbs using rotated pseudo elements*/
Expand Down Expand Up @@ -108,5 +110,5 @@
}
.flat a:hover, .flat a.active,
.flat a:hover:after, .flat a.active:after{
background: #9EEB62;
/*background: #9EEB62;*/
}
189 changes: 189 additions & 0 deletions css/style.css
@@ -0,0 +1,189 @@
path {
stroke: #fff;
fill-rule: evenodd;
}


circle,
path {

}

circle {
fill: none;
pointer-events: all;
}

circle:hover {
fill: #999;
opacity: 0.5;
}

#core:hover {
opacity: 0.5;
cursor: pointer;
}


/* treemap */

rect {
fill: none;
pointer-events: all;
}

pre {
font-size: 18px;
}

line {
stroke: #000;
stroke-width: 1.5px;
}

.string, .regexp {
color: #f39;
}

.keyword {
color: #00c;
}

.comment {
color: #777;
font-style: oblique;
}

.number {
color: #369;
}

.class, .special {
color: #1181B8;
}

/* end treemap */

body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
margin: auto;
position: relative;
overflow: none;
}

.cell > rect:hover {
fill: yellow;
}

/* legend */

#explanation {
font-family: Avenir, Arial, Helvetica, sans-serif;
position: absolute;
/*top: 260px;
left: 305px*/;
width: 140px;
height: 140px;
margin: auto;
top: 0;
left: 0;
right: 0;
bottom: 0;
text-align: center;
color: #333;
z-index: -1;
/*z-index: -1;*/
}

#core_top {
/*font-size: 2.5em;*/
}

#core_center {
font-size: 2em;
}


#legend {
text-align:center;
font-family: Avenir, Arial, Helvetica, sans-serif;
padding-top:20px;
position: absolute;
left: 0;
right: 0;
top: 40px;
z-index: 50;
}

#legend h2 {
font-size:1.2em;
font-style:inherit;
margin: 0;
padding: 0;
}
#legend p {
font-size:.9em;
margin: 0;
padding: 0;
text-transform: uppercase;
font-variant:small-caps;
}

#loading {
left: 0;
right: 0;
top: 0;
bottom: 0;
position: fixed;
display: inline-block;
margin: auto;
z-index: 10;
width: 100px;
height: 100px;
display: none;
}

.hmm {
opacity: 0.8;
cursor: pointer;
}

.hmm:hover {
stroke: #999;
stroke-width: 2px;
opacity: 1;
}

.svg-container {
display: inline-block;
position: relative;
width: 100%;
/*padding-bottom: 100%;*/ /* aspect ratio */
vertical-align: top;
overflow: hidden;
}

.svg-content-responsive {
display: inline-block;
position: absolute;
top: 10px;
left: 0;
}

#sequence {
position: absolute;
bottom: 0;
left: 0;
z-index: 100;
/*width: 600px;
height: 70px;*/
}


#chart {
position: relative;
}

#chart path {
stroke: #fff;
}
112 changes: 112 additions & 0 deletions headless.html
@@ -0,0 +1,112 @@
<html>
<head>
<title>DU headless</title>
</head>
<body>
<script>

'use strict';

const path = require('path')
const ipc = require('ipc')
const du = require('./js/du')

const ipc_name = 'du'
ipc.send('register', ipc_name)

ipc.on('ready', function() {
console.log('all is ready')
go();
})

ipc.on('broadcast', function(arg) {
console.log('[' + ipc_name + '] broadcast', arg)
})

ipc.on('message', function(arg) {
console.log('[' + ipc_name + '] message', arg)
})

function go() {

let target = '../../..'
var INCREMENTAL_INTERVAL = 30000

let checker
let json = {}
console.time('async2')

function complete(counter) {
// console.log("Scan completed", counter, "files");
console.timeEnd('async2')
clearTimeout(checker)

console.log(json);

// cache
// console.time('write')
// fs.writeFileSync('test.json', JSON.stringify(json))
// console.timeEnd('write')

ipc.send('call', 'viz', 'complete', json)
};

function refresh() {
clearTimeout(checker)
console.log('scanning...');

ipc.send('call', 'viz', 'refresh', json)
checker = setTimeout(refresh, INCREMENTAL_INTERVAL)
}

function progress(path, name) {
ipc.send('call', 'viz', 'progress', path, name)
}

target = path.resolve(target)
console.log('Scanning target', target)

// yay
du({
parent: target,
node: json,
onprogress: progress,
// onrefresh: refresh
}, complete)

setTimeout(refresh, 5000)
}


// // d3.json("flare.json", onJson);
// // for testing purposes only
// // json = fs.readFileSync('user.json', { encoding: 'utf-8'})
// // loading.style.display = 'none'
// // onJson(null, JSON.parse(json).children[10])
// // onJson(null, JSON.parse(json))
// })


</script>
<script>
// // redirect log to stdout
// console.log = require('console').log
// // redirect errors to stderr
// window.addEventListener('error', function (e) {
// e.preventDefault()
// require('console').error(e.error.stack || 'Uncaught ' + e.error)
// })

// ipc.on('args', function (args) {
// console.log('yoz i got something!!!')
// // var app
// // if (path.isAbsolute(args[2])) {
// // app = require(args[2])
// // } else {
// // app = require(path.join(process.cwd(), args[2]))
// // }
// // if (typeof app === 'function') app(args.slice(2))
// })
</script>
</body>
</html>

0 comments on commit 0c98e6f

Please sign in to comment.