Skip to content

Commit

Permalink
Optimization for matching a single array
Browse files Browse the repository at this point in the history
  • Loading branch information
davedoesdev committed Mar 6, 2016
1 parent 813f6b1 commit bbe4b47
Show file tree
Hide file tree
Showing 15 changed files with 685 additions and 469 deletions.
9 changes: 7 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,15 @@ module.exports = function (grunt)
},

bench: {
cmd: './node_modules/.bin/bench -c 10000 -i bench/options/default.js -k options'
cmd: './node_modules/.bin/bench -c 20000 -i bench/options/default.js -k options bench/add_match_remove bench/match'
},

'bench-check': {
cmd: './node_modules/.bin/bench -c 10000 -i bench/options/check.js -k options'
cmd: './node_modules/.bin/bench -c 20000 -i bench/options/check.js -k options bench/add_match_remove bench/match'
},

'bench-add-many': {
cmd: './node_modules/.bin/bench -c 1 bench/add_many.js'
}
}
});
Expand All @@ -95,5 +99,6 @@ module.exports = function (grunt)
grunt.registerTask('coveralls', 'exec:coveralls');
grunt.registerTask('bench', 'exec:bench');
grunt.registerTask('bench-check', 'exec:bench-check');
grunt.registerTask('bench-add-many', 'exec:bench-add-many');
grunt.registerTask('default', ['jslint', 'cafemocha']);
};
2 changes: 1 addition & 1 deletion LICENCE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2013 David Halls <https://github.com/davedoesdev/>
Copyright (c) 2016 David Halls <https://github.com/davedoesdev/>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
27 changes: 27 additions & 0 deletions bench/add_many.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*jslint node: true */
"use strict";

var Qlobber = require('..').Qlobber,
util = require("util"),
common = require('./common');

function Matcher()
{
Qlobber.call(this, { separator: "/", wildcard_one: "+" });
}

util.inherits(Matcher, Qlobber);

module.exports = function ()
{
var matcher = new Matcher(), i, j;

for (i = 0; i < 60000; i += 1)
{
for (j = 0; j < 5; j += 1)
{
matcher.match('app/test/user/behrad/testTopic-' + j);
matcher.add('app/test/user/behrad/testTopic-' + j, i);
}
}
};
2 changes: 1 addition & 1 deletion coverage/coverage.json

Large diffs are not rendered by default.

258 changes: 144 additions & 114 deletions coverage/lcov-report/base.css
Original file line number Diff line number Diff line change
@@ -1,107 +1,104 @@
body, html {
margin:0; padding: 0;
margin:0; padding: 0;
height: 100%;
}
body {
font-family: Helvetica Neue, Helvetica,Arial;
font-size: 10pt;
}
div.header, div.footer {
background: #eee;
padding: 1em;
}
div.header {
z-index: 100;
position: fixed;
top: 0;
border-bottom: 1px solid #666;
width: 100%;
}
div.footer {
border-top: 1px solid #666;
}
div.body {
margin-top: 10em;
}
div.meta {
font-size: 90%;
text-align: center;
}
h1, h2, h3 {
font-weight: normal;
}
h1 {
font-size: 12pt;
}
h2 {
font-size: 10pt;
}
font-family: Helvetica Neue, Helvetica, Arial;
font-size: 14px;
color:#333;
}
.small { font-size: 12px;; }
*, *:after, *:before {
-webkit-box-sizing:border-box;
-moz-box-sizing:border-box;
box-sizing:border-box;
}
h1 { font-size: 20px; margin: 0;}
h2 { font-size: 14px; }
pre {
font-family: Consolas, Menlo, Monaco, monospace;
font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace;
margin: 0;
padding: 0;
line-height: 14px;
font-size: 14px;
-moz-tab-size: 2;
-o-tab-size: 2;
tab-size: 2;
}
a { color:#0074D9; text-decoration:none; }
a:hover { text-decoration:underline; }
.strong { font-weight: bold; }
.space-top1 { padding: 10px 0 0 0; }
.pad2y { padding: 20px 0; }
.pad1y { padding: 10px 0; }
.pad2x { padding: 0 20px; }
.pad2 { padding: 20px; }
.pad1 { padding: 10px; }
.space-left2 { padding-left:55px; }
.space-right2 { padding-right:20px; }
.center { text-align:center; }
.clearfix { display:block; }
.clearfix:after {
content:'';
display:block;
height:0;
clear:both;
visibility:hidden;
}
.fl { float: left; }
@media only screen and (max-width:640px) {
.col3 { width:100%; max-width:100%; }
.hide-mobile { display:none!important; }
}

.quiet {
color: #7f7f7f;
color: rgba(0,0,0,0.5);
}
.quiet a { opacity: 0.7; }

.fraction {
font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;
font-size: 10px;
color: #555;
background: #E8E8E8;
padding: 4px 5px;
border-radius: 3px;
vertical-align: middle;
}

div.path { font-size: 110%; }
div.path a:link, div.path a:visited { color: #000; }
table.coverage { border-collapse: collapse; margin:0; padding: 0 }
div.path a:link, div.path a:visited { color: #333; }
table.coverage {
border-collapse: collapse;
margin: 10px 0 0 0;
padding: 0;
}

table.coverage td {
margin: 0;
padding: 0;
color: #111;
vertical-align: top;
margin: 0;
padding: 0;
vertical-align: top;
}
table.coverage td.line-count {
width: 50px;
text-align: right;
padding-right: 5px;
padding: 0 5px 0 20px;
}
table.coverage td.line-coverage {
color: #777 !important;
text-align: right;
border-left: 1px solid #666;
border-right: 1px solid #666;
}

table.coverage td.text {
padding-right: 10px;
min-width:20px;
}

table.coverage td span.cline-any {
display: inline-block;
padding: 0 5px;
width: 40px;
}
table.coverage td span.cline-neutral {
background: #eee;
}
table.coverage td span.cline-yes {
background: #b5d592;
color: #999;
}
table.coverage td span.cline-no {
background: #fc8c84;
width: 100%;
}

.cstat-yes { color: #111; }
.cstat-no { background: #fc8c84; color: #111; }
.fstat-no { background: #ffc520; color: #111 !important; }
.cbranch-no { background: yellow !important; color: #111; }

.cstat-skip { background: #ddd; color: #111; }
.fstat-skip { background: #ddd; color: #111 !important; }
.cbranch-skip { background: #ddd !important; color: #111; }

.missing-if-branch {
display: inline-block;
margin-right: 10px;
margin-right: 5px;
border-radius: 3px;
position: relative;
padding: 0 4px;
background: black;
background: #333;
color: yellow;
}

Expand All @@ -113,64 +110,87 @@ table.coverage td span.cline-no {
background: #ccc;
color: white;
}

.missing-if-branch .typ, .skip-if-branch .typ {
color: inherit !important;
}
.coverage-summary {
border-collapse: collapse;
width: 100%;
}
.coverage-summary tr { border-bottom: 1px solid #bbb; }
.keyline-all { border: 1px solid #ddd; }
.coverage-summary td, .coverage-summary th { padding: 10px; }
.coverage-summary tbody { border: 1px solid #bbb; }
.coverage-summary td { border-right: 1px solid #bbb; }
.coverage-summary td:last-child { border-right: none; }
.coverage-summary th {
text-align: left;
font-weight: normal;
white-space: nowrap;
}
.coverage-summary th.file { border-right: none !important; }
.coverage-summary th.pct { }
.coverage-summary th.pic,
.coverage-summary th.abs,
.coverage-summary td.pct,
.coverage-summary td.abs { text-align: right; }
.coverage-summary td.file { white-space: nowrap; }
.coverage-summary td.pic { min-width: 120px !important; }
.coverage-summary tfoot td { }

.entity, .metric { font-weight: bold; }
.metric { display: inline-block; border: 1px solid #333; padding: 0.3em; background: white; }
.metric small { font-size: 80%; font-weight: normal; color: #666; }

div.coverage-summary table { border-collapse: collapse; margin: 3em; font-size: 110%; }
div.coverage-summary td, div.coverage-summary table th { margin: 0; padding: 0.25em 1em; border-top: 1px solid #666; border-bottom: 1px solid #666; }
div.coverage-summary th { text-align: left; border: 1px solid #666; background: #eee; font-weight: normal; }
div.coverage-summary th.file { border-right: none !important; }
div.coverage-summary th.pic { border-left: none !important; text-align: right; }
div.coverage-summary th.pct { border-right: none !important; }
div.coverage-summary th.abs { border-left: none !important; text-align: right; }
div.coverage-summary td.pct { text-align: right; border-left: 1px solid #666; }
div.coverage-summary td.abs { text-align: right; font-size: 90%; color: #444; border-right: 1px solid #666; }
div.coverage-summary td.file { text-align: right; border-left: 1px solid #666; white-space: nowrap; }
div.coverage-summary td.pic { min-width: 120px !important; }
div.coverage-summary a:link { text-decoration: none; color: #000; }
div.coverage-summary a:visited { text-decoration: none; color: #333; }
div.coverage-summary a:hover { text-decoration: underline; }
div.coverage-summary tfoot td { border-top: 1px solid #666; }

div.coverage-summary .sorter {
.coverage-summary .sorter {
height: 10px;
width: 7px;
display: inline-block;
margin-left: 0.5em;
background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent;
}
div.coverage-summary .sorted .sorter {
.coverage-summary .sorted .sorter {
background-position: 0 -20px;
}
div.coverage-summary .sorted-desc .sorter {
.coverage-summary .sorted-desc .sorter {
background-position: 0 -10px;
}
.status-line { height: 10px; }
/* dark red */
.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 }
.low .chart { border:1px solid #C21F39 }
/* medium red */
.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE }
/* light red */
.low, .cline-no { background:#FCE1E5 }
/* light green */
.high, .cline-yes { background:rgb(230,245,208) }
/* medium green */
.cstat-yes { background:rgb(161,215,106) }
/* dark green */
.status-line.high, .high .cover-fill { background:rgb(77,146,33) }
.high .chart { border:1px solid rgb(77,146,33) }

.high { background: #b5d592 !important; }
.medium { background: #ffe87c !important; }
.low { background: #fc8c84 !important; }

span.cover-fill, span.cover-empty {
display:inline-block;
border:1px solid #444;
background: white;
height: 12px;
.medium .chart { border:1px solid #666; }
.medium .cover-fill { background: #666; }

.cbranch-no { background: yellow !important; color: #111; }

.cstat-skip { background: #ddd; color: #111; }
.fstat-skip { background: #ddd; color: #111 !important; }
.cbranch-skip { background: #ddd !important; color: #111; }

span.cline-neutral { background: #eaeaea; }
.medium { background: #eaeaea; }

.cover-fill, .cover-empty {
display:inline-block;
height: 12px;
}
span.cover-fill {
background: #ccc;
border-right: 1px solid #444;
.chart {
line-height: 0;
}
span.cover-empty {
.cover-empty {
background: white;
border-left: none;
}
span.cover-full {
.cover-full {
border-right: none !important;
}
pre.prettyprint {
Expand All @@ -179,4 +199,14 @@ pre.prettyprint {
margin: 0 !important;
}
.com { color: #999 !important; }
.ignore-none { color: #999; font-weight: normal; }
.ignore-none { color: #999; font-weight: normal; }

.wrapper {
min-height: 100%;
height: auto !important;
height: 100%;
margin: 0 auto -48px;
}
.footer, .push {
height: 48px;
}
Loading

0 comments on commit bbe4b47

Please sign in to comment.