Binary files orig/clucene-core-0.9.21b/src/demo/.MainStress.cpp.swp and clucene-core-0.9.21b/src/demo/.MainStress.cpp.swp differ Binary files orig/clucene-core-0.9.21b/src/demo/.SearchFilesStress.cpp.swp and clucene-core-0.9.21b/src/demo/.SearchFilesStress.cpp.swp differ diff -U 8 -prNw orig/clucene-core-0.9.21b/src/demo/Main.cpp clucene-core-0.9.21b/src/demo/Main.cpp --- orig/clucene-core-0.9.21b/src/demo/Main.cpp 2008-10-23 13:44:35.000000000 -0400 +++ clucene-core-0.9.21b/src/demo/Main.cpp 2009-03-12 16:24:34.000000000 -0400 @@ -45,17 +45,17 @@ int main( int32_t argc, char** argv ){ printf("Location to store the clucene index: "); char ndx[250]; fgets(ndx,250,stdin); ndx[strlen(ndx)-1] = 0; IndexFiles(files,ndx,true); getStats(ndx); SearchFiles(ndx); - DeleteFiles(ndx); + //DeleteFiles(ndx); }catch(CLuceneError& err){ printf(err.what()); }catch(...){ printf("Unknown error"); } _lucene_shutdown(); //clears all static memory diff -U 8 -prNw orig/clucene-core-0.9.21b/src/demo/MainSearch.cpp clucene-core-0.9.21b/src/demo/MainSearch.cpp --- orig/clucene-core-0.9.21b/src/demo/MainSearch.cpp 1969-12-31 20:00:00.000000000 -0400 +++ clucene-core-0.9.21b/src/demo/MainSearch.cpp 2009-03-12 16:24:34.000000000 -0400 @@ -0,0 +1,82 @@ +/*------------------------------------------------------------------------------ +* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team +* +* Distributable under the terms of either the Apache License (Version 2.0) or +* the GNU Lesser General Public License, as specified in the COPYING file. +------------------------------------------------------------------------------*/ +#include "stdafx.h" +#include "CLucene.h" + +#ifdef _CLCOMPILER_MSVC +#ifdef _DEBUG + #define CRTDBG_MAP_ALLOC + #include + #include +#endif +#endif + +#include + +using namespace std; + +void DeleteFiles(const char* dir); +void IndexFiles(char* path, char* target, const bool clearIndex); +void SearchFiles(const char* index); +void getStats(const char* directory); + +int main( int32_t argc, char** argv ){ + //Dumper Debug + #ifdef TR_LEAKS + #ifdef _CLCOMPILER_MSVC + #ifdef _DEBUG + _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );//| _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_CHECK_CRT_DF ); + #endif + #endif + #endif + + uint64_t str = lucene::util::Misc::currentTimeMillis(); + try{ + + //printf("Location of text files to be indexed: "); + //char files[250]; + //fgets(files,250,stdin); + //files[strlen(files)-1] = 0; + + printf("Location to clucene index: "); + char ndx[250]; + fgets(ndx,250,stdin); + ndx[strlen(ndx)-1] = 0; + + //IndexFiles(files,ndx,true); + getStats(ndx); + SearchFiles(ndx); + + //DeleteFiles(ndx); + + }catch(CLuceneError& err){ + printf(err.what()); + }catch(...){ + printf("Unknown error"); + } + + _lucene_shutdown(); //clears all static memory + //print lucenebase debug +#ifdef LUCENE_ENABLE_MEMLEAKTRACKING + lucene::debug::LuceneBase::__cl_PrintUnclosedObjects(); + //clear memtracking memory (not the unclosed objects) + lucene::debug::LuceneBase::__cl_ClearMemory(); +#endif + + //Debuggin techniques: + //For msvc, use this for breaking on memory leaks: + // _crtBreakAlloc + //to break at this clucene item: + // _lucene_counter_break + //run a memory check before deleting objects: + // _lucene_run_objectcheck + //if LUCENE_ENABLE_CONSTRUCTOR_LOG is on, dont do log if this is true: + // _lucene_disable_debuglogging + + printf ("\n\nTime taken: %d\n\n",lucene::util::Misc::currentTimeMillis() - str); + return 0; +} diff -U 8 -prNw orig/clucene-core-0.9.21b/src/demo/MainStress.cpp clucene-core-0.9.21b/src/demo/MainStress.cpp --- orig/clucene-core-0.9.21b/src/demo/MainStress.cpp 1969-12-31 20:00:00.000000000 -0400 +++ clucene-core-0.9.21b/src/demo/MainStress.cpp 2009-03-21 19:28:09.000000000 -0400 @@ -0,0 +1,90 @@ +/*------------------------------------------------------------------------------ +* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team +* +* Distributable under the terms of either the Apache License (Version 2.0) or +* the GNU Lesser General Public License, as specified in the COPYING file. +------------------------------------------------------------------------------*/ +#include "stdafx.h" +#include "CLucene.h" + +#ifdef _CLCOMPILER_MSVC +#ifdef _DEBUG + #define CRTDBG_MAP_ALLOC + #include + #include +#endif +#endif + +#include +#include + +using namespace std; + +void DeleteFiles(const char* dir); +void IndexFiles(char* path, char* target, const bool clearIndex); +//void SearchFiles(const char* index); +void SpinSearch(const char* index, GMainLoop *mainloop); +void getStats(const char* directory); + +int main( int32_t argc, char** argv ){ + //Dumper Debug + #ifdef TR_LEAKS + #ifdef _CLCOMPILER_MSVC + #ifdef _DEBUG + _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );//| _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_CHECK_CRT_DF ); + #endif + #endif + #endif + + uint64_t str = lucene::util::Misc::currentTimeMillis(); + try{ + + //printf("Location of text files to be indexed: "); + //char files[250]; + //fgets(files,250,stdin); + //files[strlen(files)-1] = 0; + + /*printf("Location to clucene index: "); + char ndx[250]; + fgets(ndx,250,stdin); + ndx[strlen(ndx)-1] = 0;*/ + char *ndx; + asprintf(&ndx, "/tmp/index"); + //asprintf(&ndx, "/home/user/clucene/index/"); + + //IndexFiles(files,ndx,true); + getStats(ndx); + //SearchFiles(ndx); + GMainLoop *mainloop = g_main_loop_new(NULL, FALSE); + SpinSearch(ndx, mainloop); + g_main_loop_run(mainloop); + + //DeleteFiles(ndx); + + }catch(CLuceneError& err){ + printf(err.what()); + }catch(...){ + printf("Unknown error"); + } + + _lucene_shutdown(); //clears all static memory + //print lucenebase debug +#ifdef LUCENE_ENABLE_MEMLEAKTRACKING + lucene::debug::LuceneBase::__cl_PrintUnclosedObjects(); + //clear memtracking memory (not the unclosed objects) + lucene::debug::LuceneBase::__cl_ClearMemory(); +#endif + + //Debuggin techniques: + //For msvc, use this for breaking on memory leaks: + // _crtBreakAlloc + //to break at this clucene item: + // _lucene_counter_break + //run a memory check before deleting objects: + // _lucene_run_objectcheck + //if LUCENE_ENABLE_CONSTRUCTOR_LOG is on, dont do log if this is true: + // _lucene_disable_debuglogging + + printf ("\n\nTime taken: %d\n\n",lucene::util::Misc::currentTimeMillis() - str); + return 0; +} diff -U 8 -prNw orig/clucene-core-0.9.21b/src/demo/Makefile.am clucene-core-0.9.21b/src/demo/Makefile.am --- orig/clucene-core-0.9.21b/src/demo/Makefile.am 2008-10-23 13:44:35.000000000 -0400 +++ clucene-core-0.9.21b/src/demo/Makefile.am 2009-03-12 16:24:34.000000000 -0400 @@ -1,20 +1,40 @@ ## Makefile.am -- Process this file with automake to produce Makefile.in -INCLUDES = -I$(top_srcdir)/src -I$(top_builddir)/src +INCLUDES = -I$(top_srcdir)/src -I$(top_builddir)/src -I/usr/include -I/usr/include/glib-2.0/ -I/usr/lib/glib-2.0/include/ + + demosrcdir = $(top_srcdir)/src/demo -bin_PROGRAMS = cl_demo +bin_PROGRAMS = cl_demo cl_demo_search cl_demo_stress cl_demo_SOURCES = $(demosrcdir)/DeleteFiles.cpp \ $(demosrcdir)/IndexFiles.cpp \ $(demosrcdir)/SearchFiles.cpp \ $(demosrcdir)/Statistics.cpp \ $(demosrcdir)/Main.cpp \ $(demosrcdir)/stdafx.cpp -cl_demo_LDADD = $(top_builddir)/src/libclucene.la +cl_demo_LDADD = $(top_builddir)/src/libclucene.la -lrt + +cl_demo_search_SOURCES = $(demosrcdir)/DeleteFiles.cpp \ + $(demosrcdir)/IndexFiles.cpp \ + $(demosrcdir)/SearchFiles.cpp \ + $(demosrcdir)/Statistics.cpp \ + $(demosrcdir)/MainSearch.cpp \ + $(demosrcdir)/stdafx.cpp + +cl_demo_search_LDADD = $(top_builddir)/src/libclucene.la -lrt + +cl_demo_stress_SOURCES = $(demosrcdir)/DeleteFiles.cpp \ + $(demosrcdir)/IndexFiles.cpp \ + $(demosrcdir)/SearchFilesStress.cpp \ + $(demosrcdir)/Statistics.cpp \ + $(demosrcdir)/MainStress.cpp \ + $(demosrcdir)/stdafx.cpp + +cl_demo_stress_LDADD = $(top_builddir)/src/libclucene.la -lrt -L/usr/lib/ -lglib-2.0 EXTRA_DIST = $(demosrcdir)/Jamfile.v2 \ $(demosrcdir)/stdafx.h \ $(demosrcdir)/CMakeLists.txt MAINTAINERCLEANFILES = Makefile.in diff -U 8 -prNw orig/clucene-core-0.9.21b/src/demo/SearchFiles.cpp clucene-core-0.9.21b/src/demo/SearchFiles.cpp --- orig/clucene-core-0.9.21b/src/demo/SearchFiles.cpp 2008-10-23 13:44:35.000000000 -0400 +++ clucene-core-0.9.21b/src/demo/SearchFiles.cpp 2009-03-12 16:24:34.000000000 -0400 @@ -4,24 +4,43 @@ * Distributable under the terms of either the Apache License (Version 2.0) or * the GNU Lesser General Public License, as specified in the COPYING file. ------------------------------------------------------------------------------*/ #include "stdafx.h" #include "CLucene.h" #include +#define TONIKITOO_TIMER + +#ifdef TONIKITOO_TIMER +#include +#include +#include +#endif + using namespace std; using namespace lucene::analysis; using namespace lucene::index; using namespace lucene::util; using namespace lucene::queryParser; using namespace lucene::document; using namespace lucene::search; +#ifdef TONIKITOO_TIMER +long _getDiffTime(struct timespec t1, struct timespec t2) +{ + if (t1.tv_nsec > t2.tv_nsec) { + t2.tv_nsec += 1000000000; + t2.tv_sec--; + } + + return 1000000000*(t2.tv_sec - t1.tv_sec)+(t2.tv_nsec - t1.tv_nsec); +} +#endif void SearchFiles(const char* index){ //Searcher searcher(index); standard::StandardAnalyzer analyzer; char line[80]; TCHAR tline[80]; const TCHAR* buf; @@ -36,30 +55,54 @@ void SearchFiles(const char* index){ STRCPY_AtoT(tline,line,80); Query* q = QueryParser::parse(tline,_T("contents"),&analyzer); buf = q->toString(_T("contents")); _tprintf(_T("Searching for: %s\n\n"), buf); _CLDELETE_CARRAY(buf); uint64_t str = lucene::util::Misc::currentTimeMillis(); + +#ifdef TONIKITOO_TIMER + long result, result_print; + struct timespec start, stop; + clock_gettime(CLOCK_REALTIME, &start); + Hits* h = s.search(q); + clock_gettime(CLOCK_REALTIME, &stop); + result = _getDiffTime(start, stop); + + clock_gettime(CLOCK_REALTIME, &start); + + for ( int32_t i=0;ilength();i++ ){ + Document* doc = &h->doc(i); + //_tprintf(_T("%d. %s - %f\n"), i, doc->get(_T("path")), h->score(i)); + cout << i << ". " << (doc->get(_T("path"))) << " = " << h->score(i) << endl; + } + + clock_gettime(CLOCK_REALTIME, &stop); + result_print = _getDiffTime(start, stop); + + printf("\n\nSearch took: %.4f ms.\n", (float) result / 1000000000.0 ); + printf("Screen dump took: %.4f ms.\n\n", (float) result_print / 1000000000.0); +#else + uint64_t str = lucene::util::Misc::currentTimeMillis(); Hits* h = s.search(q); uint64_t srch = lucene::util::Misc::currentTimeMillis() - str; str = lucene::util::Misc::currentTimeMillis(); for ( int32_t i=0;ilength();i++ ){ Document* doc = &h->doc(i); //const TCHAR* buf = doc.get(_T("contents")); _tprintf(_T("%d. %s - %f\n"), i, doc->get(_T("path")), h->score(i)); //delete doc; } printf("\n\nSearch took: %d ms.\n", srch); printf("Screen dump took: %d ms.\n\n", lucene::util::Misc::currentTimeMillis() - str); - +#endif _CLDELETE(h); _CLDELETE(q); } s.close(); //delete line; } diff -U 8 -prNw orig/clucene-core-0.9.21b/src/demo/SearchFilesStress.cpp clucene-core-0.9.21b/src/demo/SearchFilesStress.cpp --- orig/clucene-core-0.9.21b/src/demo/SearchFilesStress.cpp 1969-12-31 20:00:00.000000000 -0400 +++ clucene-core-0.9.21b/src/demo/SearchFilesStress.cpp 2009-03-19 17:47:42.000000000 -0400 @@ -0,0 +1,233 @@ +/*------------------------------------------------------------------------------ +* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team +* +* Distributable under the terms of either the Apache License (Version 2.0) or +* the GNU Lesser General Public License, as specified in the COPYING file. +------------------------------------------------------------------------------*/ +#include "stdafx.h" + +#include "CLucene.h" +#include + +#define TONIKITOO_TIMER + +#ifdef TONIKITOO_TIMER +#include +#include +#include +#include +#endif + +using namespace std; +using namespace lucene::analysis; +using namespace lucene::index; +using namespace lucene::util; +using namespace lucene::queryParser; +using namespace lucene::document; +using namespace lucene::search; + +#define MAX 1000 + +static GMainLoop *sMainLoop; +static int i = 0, failed = 0; +long total_time; +struct timespec total_start, total_stop; + +char *time_report = strdup("\t\tTime Report:\n"); +char *error_report = strdup("\n\n\t\tError Report: CLucene falied searching for:\n"); + + +char *stress[MAX] = +{ "bugs", "txt", "error", "txt", "Babel", "Distribution", "Guide", "June", "Aug", "test", "porra", + "ada", "txt", "Last", "change", "May", "AGENTX", "MIB", "DEFINITIONS" , "BEGIN", "Hi", "ArabicShaping", + "txt", "arabic", "txt", "Vim", "version", "Last", "change", "Mar", "foff", "by", "Bakker", + "seeplusplus", "users", "sourceforge", "net", "autocmd", "txt", "Vim", "version", "Last", "change", "Mar", + "BGP", "MIB", "DEFINITIONS", "BEGIN", "BidiMirroring", "txt", "Blocks", "txt", "Intro", "Babel", "Error", + "Reports", "LANGUAGE", "Filtering", "packets", "while", "capturing", "Capturing", "CaseFolding", "txt", + "LANGUAGE", "Name", "ntgclass", "COMPILING", "AND", "INSTALLING", "LANGUAGE", "change", "txt", + "Vim", "version", "Last", "change", "Jan", "LANGUAGE", "LANGUAGE", "comm", "content", "necko", + "contents", "rdf", "netwerk", "resources", "content", "contents", "rdf", "cmdline", "txt", "Vim", "version", + "Last", "change", "Jul", "The", "program", "must", "close", "to", "allow", "a", "previous", "installation", + "attempt", "to", "complete", "Please", "restart", "Introduction", "compilation", "Copyright", "information", + "at", "end", "of", "file", "CompositionExclusions", "txt", "This" , + "document", "describes", "standard", "names", "of", "mixer", "controls", "copyrite", "txt", "Operator", + "Precedence", "and", "Associativity", "Rules", "in", "C", "C++", "The", "following", "people", "have", "all", + "helped", "with", "BitTorrent", "in", "some", "way", "CREDITS", "txt", "$Id", "crop", "txt", "v", "m", "Rel", + "LANGUAGE", "Connecting", "to", "MySQL", "server", "on", "a", "remote", "machine", "using", "ODBC", "debugger", + "txt", "Vim", "version", "Last", "change", "Mar", "debug", "txt", "Vim", "version", "Last", "change", "May", + "Sapphire", "Skin", "by", "Gustavo", "A", "Version", "LANGUAGE", "develop", "txt", "Vim", "version", "Last", + "change", "May", "diff", "txt", "Vim", "version", "Last", "change", "Oct", "digraph", "txt", "Vim", "version", + "Last", "change", "Jul", "DISMAN", "EVENT", "MIB", "DEFINITIONS", "BEGIN", "DISMAN", "SCHEDULE", "MIB", "DEFINITIONS", + "BEGIN", "DISMAN", "SCRIPT", "MIB", "DEFINITIONS", "BEGIN", "Filtering", "packets", "while", "viewing", "The", + "following", "SNIPPETS", "files", "are", "either", "MS", "PC", "DOS", "specific", "or", "have", "limited", + "Help", "for", "GIT", "s", "DPKG", "Commands", "EastAsianWidth", "txt", "ec", "chg", "txt", "editing", + "txt", "Vim", "version", "Last", "change", "May", "LANGUAGE", "adopted", "from", "a", "message", "that", "Ives", + "posted", "in", "the", "Vim", "mailing", "list", "This", "document", "is", "a", "guide", "to", "using", "the", "emu", + "k", "based", "devices", "with", "JACK", "for", "low", "distutils", "commands", "enumerator", "txt", "Indented", + "Text", "Some", "of", "my", "favorites", "Q", "Why", "was", "only", "the", "DOS", "batch", "file", "and", "Stuff", + "key", "buffer", "method", "Updated", "etc", "txt", "Indented", "Text", "created", "at", "Fri", "Jul", "JST", + "EtherLike", "MIB", "DEFINITIONS", "BEGIN", "euc", "cn", "txt", "EUC", "to", "Unicode", "charmap", "euc", "jp", + "txt", "EUC", "to", "Unicode", "charmap", "euc", "kr", "txt", "EUC", "to", "Unicode", "charmap", "euc", "tw", + "txt", "EUC", "to", "Unicode", "charmap", "$Id", "euro", "txt", "v", "m", "Exp", "eval", "txt", "Vim", "version", + "Last", "change", "Jul", "To", "blank", "EGA", "VGA", "screen", "read", "flipflop", "at", "x", "DA", "then", "write", + "x", "Writing", "an", "IDLE", "extension", "The", "mercurial", "FAQ", "is", "now", "maintained", "on", "a", "Wiki", + "page", "Look", "at", "the", "URL", "farsi", "txt", "Vim", "version", "Last", "change", "Mar", "guint", "bit", "msbf", + "filetype", "txt", "Vim", "version", "Last", "change", "May", "Fingerprints", "LANGUAGE", "Fixes", "since", "last", + "major", "release", "a", "fold", "txt", "Vim", "version", "Last", "change", "May", "LANGUAGE", "usr", "bin", "perl", + "usr", "bin", "perl", "Getting", "started", "gitview", "From", "lars", "Thu", "Feb", "LANGUAGE", "Introduction", "grep", + "See", "the", "end", "of", "file", "for", "copyright", "information", "gui", "txt", "Vim", "version", "Last", "change", + "May", "gui", "w", "txt", "Vim", "version", "Last", "change", "Mar", "gui", "w", "txt", "Vim", "version", "Last", + "change", "May", "gui", "x", "txt", "Vim", "version", "Last", "change", "Jul", "hangulin", "txt", "Vim", "version", + "Last", "change", "Apr", "HangulSyllableType", "txt", "HCNUM", "TC", "DEFINITIONS", "BEGIN", "hebrew", "txt", "Vim", + "version", "Last", "change", "May", "Die", "Aptitude", "Online", "Hilfe", "Ayuda", "en", "lĂ­nea", "de", "Aptitude", + "Aptitude", "On", "Line", "Help", "Format", "Aptituden", "pika", "apu", "Aide", "en", "ligne", "d", "Aptitude", "Axuda", + "En", "de", "Aptitude", "Guida", "online", "di", "Aptitude", "Aptitude", "BEGIN", "IF", "MIB", "DEFINITIONS", "BEGIN", + "if", "mzsch", "txt", "Vim", "version", "Last", "change", "May", "if", "ole", "txt", "Vim", "version", "Last", "change", + "May", "if", "perl", "txt", "Vim", "version", "Last", "change", "Mar", "if", "pyth", "txt", "Vim", "version", "Last", + "change", "Apr", "if", "ruby", "txt", "Vim", "version", "Last", "change", "Apr", "if", "sniff", "txt", "Vim", "version", + "Last", "change", "Mar", "if", "tcl", "txt", "Vim", "version", "Last", "change", "Mar", "indent", "txt", "Vim", "version", + "Last", "change", "May", "index", "txt", "Vim", "version", "Last", "change", "May", "Latin", "Based", "on", "ISO", "A", + "INET", "ADDRESS", "MIB", "DEFINITIONS", "BEGIN", "insert", "txt", "Vim", "version", "Last", "change", "May", "locale", + "install", "url", "jar", "resource", "chrome", "en", "US", "jar", "locale", "en", "US", "wallet", "intro", "txt", "Vim", + "version", "Last", "change", "May", "PROLOGUE", "IP", "FORWARD", "MIB", "DEFINITIONS", "BEGIN", "IP", "MIB", "DEFINITIONS", + "BEGIN", "IPV", "ICMP", "MIB", "DEFINITIONS", "BEGIN", "IPV", "MIB", "DEFINITIONS", "BEGIN", "IPV", "TCP", "MIB", + "DEFINITIONS", "BEGIN", "IPV", "TC", "DEFINITIONS", "BEGIN", "IPV", "UDP", "MIB", "DEFINITIONS", "BEGIN", "txt", "Legacy", + "SBCS", "to", "Unicode", "charmap", "LANGUAGE", "LANGUAGE", "Analog", "Joystick", "Support", "on", "ALSA", "Drivers", + "Header", "for", "agentlib", "hprof", "or", "Xrunhprof", "ASCII", "Output", "J", "SE", "JVMTI", "based", "This", "file", + "is", "generated", "from", "allkeys", "txt", "unicode", "org", "jrv", "vanzandt", "mv", "com", "Jim", "Van", "Zandt", "writes", + "koi", "r", "txt", "Legacy", "SBCS", "to", "Unicode", "charmap", "koi", "u", "txt", "Legacy", "SBCS", "to", "Unicode", + "charmap", "LaTeX", "Copyright", "Warranty", "and", "Distribution", "Restrictions", "FUNC", "ZN", "cxxabiv", "terminateEPFvvE", + "A", "HISTORY", "OF", "THE", "SOFTWARE", "LineBreak", "txt", "LM", "SENSORS", "MIB", "DEFINITIONS", "BEGIN", "BEGIN", + "AUTOGENERATED", "DATA", "LANGUAGE", "x", "x", "SPACE", "LANGUAGE", "NAME" }; + +#ifdef TONIKITOO_TIMER +long _getDiffTimeNSec(struct timespec t1, struct timespec t2) +{ + if (t1.tv_nsec > t2.tv_nsec) { + t2.tv_nsec += 1000000000; + t2.tv_sec--; + } + + return 1000000000*(t2.tv_sec - t1.tv_sec)+(t2.tv_nsec - t1.tv_nsec); +} +long _getDiffTimeSec(struct timespec t1, struct timespec t2) +{ + if (t1.tv_nsec > t2.tv_nsec) { + t2.tv_nsec += 1000000000; + t2.tv_sec--; + } + return (t2.tv_sec - t1.tv_sec); +} +#endif + +gboolean SearchFiles(gpointer index){ + standard::StandardAnalyzer analyzer; + TCHAR tline[80]; + const TCHAR* buf; + long result, result_print; + struct timespec start, stop, start_result, stop_result; + + clock_gettime(CLOCK_REALTIME, &start_result); + + IndexSearcher s((char *)index); + STRCPY_AtoT(tline, stress[i], 80); + Query* q = QueryParser::parse(tline,_T("contents"),&analyzer); + if (!q) { + i++; + failed++; + char *cur_error; + asprintf(&cur_error, "\t\"%20s\" [%d]\n", stress[i], i); + char *tmp_accum_error; + asprintf(&tmp_accum_error, "%s%s", error_report, cur_error); + + free(cur_error); + cur_error = NULL; + + free(error_report); + error_report = strdup(tmp_accum_error); + + return TRUE; + } + //buf = q->toString(_T("contents")); + //_tprintf(_T("Searching for: %s\n"), buf); + //_CLDELETE_CARRAY(buf); + + clock_gettime(CLOCK_REALTIME, &start); + + Hits* h = s.search(q); + + clock_gettime(CLOCK_REALTIME, &stop); + result = _getDiffTimeNSec(start, stop); + + //for ( int32_t i=0;ilength();i++ ){ + // Document* doc = &h->doc(i); + //_tprintf(_T("%d. %s - %f\n"), i, doc->get(_T("path")), h->score(i)); + //} + +#if 0 + uint64_t str = lucene::util::Misc::currentTimeMillis(); + Hits* h = s.search(q); + uint64_t srch = lucene::util::Misc::currentTimeMillis() - str; + str = lucene::util::Misc::currentTimeMillis(); + + for ( int32_t i=0;ilength();i++ ) { + Document* doc = &h->doc(i); + //const TCHAR* buf = doc.get(_T("contents")); + _tprintf(_T("%d. %s - %f\n"), i, doc->get(_T("path")), h->score(i)); + //delete doc; + } + + printf("\n\nSearch took: %d ms.\n", srch); + printf("Screen dump took: %d ms.\n\n", lucene::util::Misc::currentTimeMillis() - str); + +#endif + + _CLDELETE(h); + _CLDELETE(q); + + s.close(); + + clock_gettime(CLOCK_REALTIME, &stop_result); + result_print = _getDiffTimeNSec(start_result, stop_result); + + char *cur_rep; + asprintf(&cur_rep, "\t\"%15s\" [%f] [%f]\n", stress[i], (float) result / 1000000000.0, (float) result_print / 1000000000.0); + char *tmp_accum_time; + asprintf(&tmp_accum_time, "%s%s", time_report, cur_rep); + + free(cur_rep); + cur_rep = NULL; + + free(time_report); + time_report = strdup(tmp_accum_time); + free(tmp_accum_time); + tmp_accum_time = NULL; + + if (!strcmp(stress[i], "NAME")) { + clock_gettime(CLOCK_REALTIME, &total_stop); + total_time = _getDiffTimeSec(total_start, total_stop); + printf("REPORT: total %d failed %d time %lds\n\n", i, failed, total_time); + printf("%s", time_report); + printf("%s", error_report); + free(time_report); + time_report = NULL; + g_main_loop_quit(sMainLoop); + return FALSE; + } + + i++; + + free(error_report); + error_report = NULL; + + return TRUE; + //delete line; +} + +void SpinSearch(const char* index, GMainLoop *mainloop) { + printf("SpinSearch\n"); + sMainLoop = mainloop; + clock_gettime(CLOCK_REALTIME, &total_start); + g_timeout_add(50, SearchFiles, (void *) index); +} + Binary files orig/clucene-core-0.9.21b/src/demo/core and clucene-core-0.9.21b/src/demo/core differ