Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qf Stats #22

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions results/js/Smart.TimeResultFormatting.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ function showDivs(document, divClass, show) {
}
}

function showDivsByName(document, divName, show) {
const divs = document.getElementsByName(divName);
const displayValue = show ? 'block' : 'none';
for (const counter in divs) {
divs[counter].style.display = displayValue;
}
}

function findChildWithClassNames(parent, namesOfClass) {
const parentChildren = parent.children;
for (let counter = 0; counter < parentChildren.length; counter++) {
Expand Down
57 changes: 57 additions & 0 deletions results/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ td{
vertical-align:middle;
}

.statNames {
background-color: #666666;
font-size: 11px;
text-align:center;
color: #eeeeee;
vertical-align:middle;
}

.didascalia {
width: 70px;
float: left;
Expand Down Expand Up @@ -197,6 +205,55 @@ td{
color: #888888;
}

.search_stats {
padding: 2px;
width: 60px;
height: 15px;
font-size: 11px;
text-align:center;
border-radius: 8px;
margin-top:3px;
margin-bottom:3px;
color: #000000;
vertical-align:middle;
}

.search_stats_best {
padding: 2px;
background-color: Honeydew;
width: 60px;
height: 10px;
font-size: 10px;
text-align:center;
border-radius: 4px;
color: #333333;
vertical-align:middle;
}

.search_stats_worst {
padding: 2px;
background-color: LavenderBlush;
width: 60px;
height: 10px;
font-size: 10px;
text-align:center;
vertical-align:middle;
border-radius: 4px;
color: #333333;
}

.search_stats_none {
padding: 2px;
background-color: #ffffff;
width: 60px;
height: 15px;
font-size: 10px;
text-align:center;
vertical-align:middle;
border-radius: 4px;
color: #000000;
}

.main_container {
width:1020px;
}
Expand Down
77 changes: 76 additions & 1 deletion source/algos/hash3.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
*/

#include "include/define.h"
#include "include/main.h"
#include "include/mainstats.h" // defines the search interface for time and statistics.
#include "include/shiftstats.h" // implements the standard set of shift-table algorithm statistic names.

#define RANK3 3

int search(unsigned char *x, int m, unsigned char *y, int n) {
Expand Down Expand Up @@ -82,3 +84,76 @@ int search(unsigned char *x, int m, unsigned char *y, int n) {
}
}
}

struct searchInfo searchStats(unsigned char *x, int m, unsigned char *y, int n) {
int count, j, i, sh, sh1, mMinus1, mMinus2, shift[WSIZE];
unsigned char h;
if(m<3) return NO_ALGO_RESULTS;
count = 0;
mMinus1 = m-1;
mMinus2 = m-2;

for (i = 0; i < WSIZE; ++i)
shift[i] = mMinus2;

h = x[0];
h = ((h<<1) + x[1]);
h = ((h<<1) + x[2]);
shift[h] = m-RANK3;
for (i=RANK3; i < mMinus1; ++i) {
h = x[i-2];
h = ((h<<1) + x[i-1]);
h = ((h<<1) + x[i]);
shift[h] = mMinus1-i;
}
h = x[i-2];
h = ((h<<1) + x[i-1]);
h = ((h<<1) + x[i]);
sh1 = shift[h];
shift[h] = 0;
if(sh1==0) sh1=1;

/* Basic search info */
struct searchInfo results = {0};
initStats(&results, n, WSIZE, sizeof(int));

/* Table stats */
sumTable(0, &results, shift, WSIZE);

i = mMinus1;
memcpy(y+n, x, m);
while (1) {
results.mainLoopCount++;

sh = 1;
while (sh != 0) {
h = y[i-2];
h = ((h<<1) + y[i-1]);
h = ((h<<1) + y[i]);
results.textBytesRead += 3;

sh = shift[h];
results.indexLookupCount++;

i+=sh;
results.numShifts++;
}
if (i < n) {
results.validationCount++;
j=0;
while(++results.textBytesRead && ++results.validationBytesRead && j<m && x[j]==y[i-mMinus1+j]) {
j++;
}
if (j>=m) {
results.matchCount++;
}
i+=sh1;
results.validationShifts += sh1;
results.numShifts++;
}
else {
return results;
}
}
}

86 changes: 85 additions & 1 deletion source/algos/hash5.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
*/

#include "include/define.h"
#include "include/main.h"
#include "include/mainstats.h" // defines the search interface for time and statistics.
#include "include/shiftstats.h" // implements the standard set of shift-table algorithm statistic names.

#define RANK5 5

int search(unsigned char *x, int m, unsigned char *y, int n) {
Expand Down Expand Up @@ -90,3 +92,85 @@ int search(unsigned char *x, int m, unsigned char *y, int n) {
}
}
}


struct searchInfo searchStats(unsigned char *x, int m, unsigned char *y, int n) {
int count,i, j,sh, shift[WSIZE], sh1, mMinus1, mMinus4;
unsigned int h;
if(m<5) return NO_ALGO_RESULTS;

/* Preprocessing */
count = 0;
mMinus1 = m-1;
mMinus4 = m-4;
for (i = 0; i < WSIZE; ++i)
shift[i] = mMinus4;

h = x[0];
h = ((h<<1) + x[1]);
h = ((h<<1) + x[2]);
h = ((h<<1) + x[3]);
h = ((h<<1) + x[4]);
shift[h%WSIZE] = m-RANK5;
for (i=RANK5; i < mMinus1; ++i) {
h = x[i-4];
h = ((h<<1) + x[i-3]);
h = ((h<<1) + x[i-2]);
h = ((h<<1) + x[i-1]);
h = ((h<<1) + x[i]);
shift[h%WSIZE] = mMinus1-i;
}
h = x[i-4];
h = ((h<<1) + x[i-3]);
h = ((h<<1) + x[i-2]);
h = ((h<<1) + x[i-1]);
h = ((h<<1) + x[i]);
sh1 = shift[h%WSIZE];
shift[h%WSIZE] = 0;
if(sh1==0) sh1=1;

/* Basic search info */
struct searchInfo results = {0};
initStats(&results, n, WSIZE, sizeof(int));

/* Table stats */
sumTable(0, &results, shift, WSIZE);

i = mMinus1;
memcpy(y+n, x, m);
while (1) {
results.mainLoopCount++;

sh = 1;
while (sh != 0) {
h = y[i-4];
h = ((h<<1) + y[i-3]);
h = ((h<<1) + y[i-2]);
h = ((h<<1) + y[i-1]);
h = ((h<<1) + y[i]);
results.textBytesRead += 5;

sh = shift[h%WSIZE];
results.indexLookupCount++;

i+=sh;
results.numShifts++;
}
if (i < n) {
results.validationCount++;
j=0;
while(++results.textBytesRead && ++results.validationBytesRead && j<m && x[j]==y[i-mMinus1+j]) {
j++;
}
if (j>=m) {
results.matchCount++;
}
i+=sh1;
results.validationShifts += sh1;
results.numShifts++;
}
else {
return results;
}
}
}
98 changes: 97 additions & 1 deletion source/algos/hash8.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
*/

#include "include/define.h"
#include "include/main.h"
#include "include/mainstats.h" // defines the search interface for time and statistics.
#include "include/shiftstats.h" // implements the standard set of shift-table algorithm statistic names.

#define RANK8 8

int search(unsigned char *x, int m, unsigned char *y, int n) {
Expand Down Expand Up @@ -103,3 +105,97 @@ int search(unsigned char *x, int m, unsigned char *y, int n) {
}
}
}


struct searchInfo searchStats(unsigned char *x, int m, unsigned char *y, int n) {
int i, j, sh, shift[WSIZE], sh1, mMinus1, mMinus7;
unsigned int h;
if(m<8) return NO_ALGO_RESULTS;

/* Preprocessing */
mMinus1 = m-1;
mMinus7 = m-7;
for (i = 0; i < WSIZE; ++i)
shift[i] = mMinus7;

h = x[0];
h = ((h<<1) + x[1]);
h = ((h<<1) + x[2]);
h = ((h<<1) + x[3]);
h = ((h<<1) + x[4]);
h = ((h<<1) + x[5]);
h = ((h<<1) + x[6]);
h = ((h<<1) + x[7]);
shift[h%WSIZE] = m-RANK8;
for (i=RANK8; i < mMinus1; ++i) {
h = x[i-7];
h = ((h<<1) + x[i-6]);
h = ((h<<1) + x[i-5]);
h = ((h<<1) + x[i-4]);
h = ((h<<1) + x[i-3]);
h = ((h<<1) + x[i-2]);
h = ((h<<1) + x[i-1]);
h = ((h<<1) + x[i]);
shift[h%WSIZE] = mMinus1-i;
}
h = x[i-7];
h = ((h<<1) + x[i-6]);
h = ((h<<1) + x[i-5]);
h = ((h<<1) + x[i-4]);
h = ((h<<1) + x[i-3]);
h = ((h<<1) + x[i-2]);
h = ((h<<1) + x[i-1]);
h = ((h<<1) + x[i]);
sh1 = shift[h%WSIZE];
shift[h%WSIZE] = 0;
if(sh1==0) sh1=1;

/* Basic search info */
struct searchInfo results = {0};
initStats(&results,n, WSIZE, sizeof(int));

/* Table stats */
sumTable(0, &results, shift, WSIZE);

/* Searching */
i = mMinus1;
memcpy(y+n, x, m);
while (1) {
results.mainLoopCount++;

sh = 1;
while (sh != 0) {
h = y[i-7];
h = ((h<<1) + y[i-6]);
h = ((h<<1) + y[i-5]);
h = ((h<<1) + y[i-4]);
h = ((h<<1) + y[i-3]);
h = ((h<<1) + y[i-2]);
h = ((h<<1) + y[i-1]);
h = ((h<<1) + y[i]);
results.textBytesRead += 8;

sh = shift[h%WSIZE];
results.indexLookupCount++;

i+=sh;
results.numShifts++;
}
if (i < n) {
results.validationCount++;
j=0;
while(++results.textBytesRead && ++results.validationBytesRead && j<m && x[j]==y[i-mMinus1+j]) {
j++;
}
if (j>=m) {
results.matchCount++;
}
i+=sh1;
results.validationShifts += sh1;
results.numShifts++;
}
else {
return results;
}
}
}
17 changes: 17 additions & 0 deletions source/algos/include/bitstats.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// Created by matt on 05/05/2022.
//

#include "../../searchinfo.h"

#ifndef SMART_BITSTATS_H
#define SMART_BITSTATS_H

struct algoValueNames getAlgoValueNames() {
struct algoValueNames names = {0};
setAlgoValueName(&names, 0, "bits", "Count of bits set in index");
setAlgoValueName(&names, 1, "empty", "Count of empty index entries");
return names;
}

#endif //SMART_BITSTATS_H
Loading