lucene-cli: Added benchmark commands, tests and documentation
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/4a8507a1 Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/4a8507a1 Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/4a8507a1 Branch: refs/heads/master Commit: 4a8507a1941503ce17823dce748ace1bd953b89e Parents: 564a292 Author: Shad Storhaug <s...@shadstorhaug.com> Authored: Mon Aug 7 00:14:41 2017 +0700 Committer: Shad Storhaug <s...@shadstorhaug.com> Committed: Mon Aug 7 00:14:41 2017 +0700 ---------------------------------------------------------------------- .../ByTask/Programmatic/Sample.cs | 2 +- .../Commands/Benchmark/BenchmarkCommandTest.cs | 50 ++++++ .../BenchmarkExtractReutersCommandTest.cs | 61 +++++++ .../BenchmarkExtractWikipediaCommandTest.cs | 66 +++++++ .../BenchmarkFindQualityQueriesCommandTest.cs | 65 +++++++ .../Benchmark/BenchmarkRunCommandTest.cs | 60 +++++++ .../BenchmarkRunTrecEvalCommandTest.cs | 63 +++++++ .../lucene-cli/Resources/Strings.Designer.cs | 171 +++++++++++++++++++ src/tools/lucene-cli/Resources/Strings.resx | 57 +++++++ src/tools/lucene-cli/commands/RootCommand.cs | 4 +- .../commands/benchmark/BenchmarkCommand.cs | 51 ++++++ .../BenchmarkExtractReutersCommand.cs | 52 ++++++ .../BenchmarkExtractWikipediaCommand.cs | 72 ++++++++ .../BenchmarkFindQualityQueriesCommand.cs | 51 ++++++ .../BenchmarkRunTrecEvalCommand.cs | 78 +++++++++ .../benchmark-run/BenchmarkRunCommand.cs | 50 ++++++ .../benchmark-sample/BenchmarkSampleCommand.cs | 53 ++++++ .../commands/demo/DemoConfiguration.cs | 1 + .../docs/benchmark/extract-reuters.md | 31 ++++ .../docs/benchmark/extract-wikipedia.md | 35 ++++ .../docs/benchmark/find-quality-queries.md | 27 +++ src/tools/lucene-cli/docs/benchmark/index.md | 14 ++ .../lucene-cli/docs/benchmark/run-trec-eval.md | 51 ++++++ src/tools/lucene-cli/docs/benchmark/run.md | 31 ++++ src/tools/lucene-cli/docs/benchmark/sample.md | 29 ++++ src/tools/lucene-cli/project.json | 2 + 26 files changed, 1223 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4a8507a1/src/Lucene.Net.Benchmark/ByTask/Programmatic/Sample.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Benchmark/ByTask/Programmatic/Sample.cs b/src/Lucene.Net.Benchmark/ByTask/Programmatic/Sample.cs index 6b248f6..3dbb07b 100644 --- a/src/Lucene.Net.Benchmark/ByTask/Programmatic/Sample.cs +++ b/src/Lucene.Net.Benchmark/ByTask/Programmatic/Sample.cs @@ -72,7 +72,7 @@ namespace Lucene.Net.Benchmarks.ByTask.Programmatic var p = new Dictionary<string, string>(); p["task.max.depth.log"] = "3"; p["max.buffered"] = "buf:10:10:100:100:10:10:100:100"; - p["doc.maker"] = "Lucene.Net.Benchmarks.ByTask.Feeds.ReutersContentSource, Lucene.Net.Benchmark"; + //p["doc.maker"] = "Lucene.Net.Benchmarks.ByTask.Feeds.ReutersContentSource, Lucene.Net.Benchmark"; p["log.step"] = "2000"; p["doc.delete.step"] = "8"; p["analyzer"] = "Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net.Analysis.Common"; http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4a8507a1/src/tools/Lucene.Net.Tests.Cli/Commands/Benchmark/BenchmarkCommandTest.cs ---------------------------------------------------------------------- diff --git a/src/tools/Lucene.Net.Tests.Cli/Commands/Benchmark/BenchmarkCommandTest.cs b/src/tools/Lucene.Net.Tests.Cli/Commands/Benchmark/BenchmarkCommandTest.cs new file mode 100644 index 0000000..999b282 --- /dev/null +++ b/src/tools/Lucene.Net.Tests.Cli/Commands/Benchmark/BenchmarkCommandTest.cs @@ -0,0 +1,50 @@ +using Lucene.Net.Attributes; +using Lucene.Net.Cli.CommandLine; +using NUnit.Framework; +using System.Collections.Generic; + +namespace Lucene.Net.Cli.Commands +{ + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + public class BenchmarkCommandTest : CommandTestCase + { + protected override ConfigurationBase CreateConfiguration(MockConsoleApp app) + { + return new DemoCommand.Configuration(new CommandLineOptions()) { Main = (args) => app.Main(args) }; + } + + protected override IList<Arg[]> GetOptionalArgs() + { + // NOTE: We must order this in the sequence of the expected output. + return new List<Arg[]>(); + } + protected override IList<Arg[]> GetRequiredArgs() + { + // NOTE: We must order this in the sequence of the expected output. + return new List<Arg[]>(); + } + + [Test] + [LuceneNetSpecific] + public virtual void TestTooManyArguments() + { + Assert.Throws<CommandParsingException>(() => AssertConsoleOutput("one", "")); + } + } +} http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4a8507a1/src/tools/Lucene.Net.Tests.Cli/Commands/Benchmark/BenchmarkExtractReutersCommandTest.cs ---------------------------------------------------------------------- diff --git a/src/tools/Lucene.Net.Tests.Cli/Commands/Benchmark/BenchmarkExtractReutersCommandTest.cs b/src/tools/Lucene.Net.Tests.Cli/Commands/Benchmark/BenchmarkExtractReutersCommandTest.cs new file mode 100644 index 0000000..7d0c947 --- /dev/null +++ b/src/tools/Lucene.Net.Tests.Cli/Commands/Benchmark/BenchmarkExtractReutersCommandTest.cs @@ -0,0 +1,61 @@ +using Lucene.Net.Attributes; +using Lucene.Net.Cli.CommandLine; +using NUnit.Framework; +using System.Collections.Generic; + +namespace Lucene.Net.Cli.Commands +{ + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + public class BenchmarkExtractReutersCommandTest : CommandTestCase + { + protected override ConfigurationBase CreateConfiguration(MockConsoleApp app) + { + return new BenchmarkExtractReutersCommand.Configuration(new CommandLineOptions()) { Main = (args) => app.Main(args) }; + } + + protected override IList<Arg[]> GetOptionalArgs() + { + return new List<Arg[]>(); + } + + protected override IList<Arg[]> GetRequiredArgs() + { + // NOTE: We must order this in the sequence of the expected output. + return new List<Arg[]>() + { + new Arg[] { new Arg(inputPattern: @"C:\lucene-temp", output: new string[] { @"C:\lucene-temp" }) }, + new Arg[] { new Arg(inputPattern: @"C:\lucene-temp2", output: new string[] { @"C:\lucene-temp2" }) }, + }; + } + + [Test] + [LuceneNetSpecific] + public virtual void TestNotEnoughArguments() + { + AssertConsoleOutput("one", FromResource("NotEnoughArguments", 2)); + } + + [Test] + [LuceneNetSpecific] + public virtual void TestTooManyArguments() + { + Assert.Throws<CommandParsingException>(() => AssertConsoleOutput("one two three", "")); + } + } +} http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4a8507a1/src/tools/Lucene.Net.Tests.Cli/Commands/Benchmark/BenchmarkExtractWikipediaCommandTest.cs ---------------------------------------------------------------------- diff --git a/src/tools/Lucene.Net.Tests.Cli/Commands/Benchmark/BenchmarkExtractWikipediaCommandTest.cs b/src/tools/Lucene.Net.Tests.Cli/Commands/Benchmark/BenchmarkExtractWikipediaCommandTest.cs new file mode 100644 index 0000000..f5d3477 --- /dev/null +++ b/src/tools/Lucene.Net.Tests.Cli/Commands/Benchmark/BenchmarkExtractWikipediaCommandTest.cs @@ -0,0 +1,66 @@ +using Lucene.Net.Attributes; +using Lucene.Net.Cli.CommandLine; +using NUnit.Framework; +using System.Collections.Generic; + +namespace Lucene.Net.Cli.Commands +{ + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + public class BenchmarkExtractWikipediaCommandTest : CommandTestCase + { + protected override ConfigurationBase CreateConfiguration(MockConsoleApp app) + { + return new BenchmarkExtractWikipediaCommand.Configuration(new CommandLineOptions()) { Main = (args) => app.Main(args) }; + } + + protected override IList<Arg[]> GetOptionalArgs() + { + return new List<Arg[]>() + { + new Arg[] { new Arg(inputPattern: "-d|--discard-image-only-docs", output: new string[] { "--discardImageOnlyDocs" }) }, + }; + } + + protected override IList<Arg[]> GetRequiredArgs() + { + // NOTE: We must order this in the sequence of the expected output. + return new List<Arg[]>() + { + new Arg[] { new Arg(inputPattern: @"", output: new string[] { "--input" }) }, + new Arg[] { new Arg(inputPattern: @"C:\lucene-temp\docs.txt", output: new string[] { @"C:\lucene-temp\docs.txt" }) }, + new Arg[] { new Arg(inputPattern: @"", output: new string[] { "--output" }) }, + new Arg[] { new Arg(inputPattern: @"C:\lucene-temp2", output: new string[] { @"C:\lucene-temp2" }) }, + }; + } + + [Test] + [LuceneNetSpecific] + public virtual void TestNotEnoughArguments() + { + AssertConsoleOutput("one", FromResource("NotEnoughArguments", 2)); + } + + [Test] + [LuceneNetSpecific] + public virtual void TestTooManyArguments() + { + Assert.Throws<CommandParsingException>(() => AssertConsoleOutput("one two three", "")); + } + } +} http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4a8507a1/src/tools/Lucene.Net.Tests.Cli/Commands/Benchmark/BenchmarkFindQualityQueriesCommandTest.cs ---------------------------------------------------------------------- diff --git a/src/tools/Lucene.Net.Tests.Cli/Commands/Benchmark/BenchmarkFindQualityQueriesCommandTest.cs b/src/tools/Lucene.Net.Tests.Cli/Commands/Benchmark/BenchmarkFindQualityQueriesCommandTest.cs new file mode 100644 index 0000000..738040e --- /dev/null +++ b/src/tools/Lucene.Net.Tests.Cli/Commands/Benchmark/BenchmarkFindQualityQueriesCommandTest.cs @@ -0,0 +1,65 @@ +using Lucene.Net.Attributes; +using Lucene.Net.Cli.CommandLine; +using NUnit.Framework; +using System.Collections.Generic; + +namespace Lucene.Net.Cli.Commands +{ + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + public class BenchmarkFindQualityQueriesCommandTest : CommandTestCase + { + protected override ConfigurationBase CreateConfiguration(MockConsoleApp app) + { + return new BenchmarkFindQualityQueriesCommand.Configuration(new CommandLineOptions()) { Main = (args) => app.Main(args) }; + } + + protected override IList<Arg[]> GetOptionalArgs() + { + // NOTE: We must order this in the sequence of the expected output. + return new List<Arg[]>(); + } + + protected override IList<Arg[]> GetRequiredArgs() + { + // NOTE: We must order this in the sequence of the expected output. + return new List<Arg[]>() + { + new Arg[] { new Arg(inputPattern: @"C:\lucene-temp", output: new string[] { @"C:\lucene-temp" }) }, + }; + } + + /// <summary> + /// Ensures the current working directory is used when index directory is not supplied. + /// </summary> + [Test] + [LuceneNetSpecific] + public virtual void TestNoArguments() + { + System.IO.Directory.SetCurrentDirectory(@"C:\"); + AssertCommandTranslation("", new string[] { @"C:\" }); + } + + [Test] + [LuceneNetSpecific] + public virtual void TestTooManyArguments() + { + Assert.Throws<CommandParsingException>(() => AssertConsoleOutput("one two", "")); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4a8507a1/src/tools/Lucene.Net.Tests.Cli/Commands/Benchmark/BenchmarkRunCommandTest.cs ---------------------------------------------------------------------- diff --git a/src/tools/Lucene.Net.Tests.Cli/Commands/Benchmark/BenchmarkRunCommandTest.cs b/src/tools/Lucene.Net.Tests.Cli/Commands/Benchmark/BenchmarkRunCommandTest.cs new file mode 100644 index 0000000..ab87b70 --- /dev/null +++ b/src/tools/Lucene.Net.Tests.Cli/Commands/Benchmark/BenchmarkRunCommandTest.cs @@ -0,0 +1,60 @@ +using Lucene.Net.Attributes; +using Lucene.Net.Cli.CommandLine; +using NUnit.Framework; +using System.Collections.Generic; + +namespace Lucene.Net.Cli.Commands +{ + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + public class BenchmarkRunCommandTest : CommandTestCase + { + protected override ConfigurationBase CreateConfiguration(MockConsoleApp app) + { + return new BenchmarkRunCommand.Configuration(new CommandLineOptions()) { Main = (args) => app.Main(args) }; + } + + protected override IList<Arg[]> GetOptionalArgs() + { + // NOTE: We must order this in the sequence of the expected output. + return new List<Arg[]>(); + } + protected override IList<Arg[]> GetRequiredArgs() + { + // NOTE: We must order this in the sequence of the expected output. + return new List<Arg[]>() + { + new Arg[] { new Arg(inputPattern: @"C:\lucene-temp\test.alg", output: new string[] { @"C:\lucene-temp\test.alg" }) }, + }; + } + + [Test] + [LuceneNetSpecific] + public virtual void TestNotEnoughArguments() + { + AssertConsoleOutput("", FromResource("NotEnoughArguments", 1)); + } + + [Test] + [LuceneNetSpecific] + public virtual void TestTooManyArguments() + { + Assert.Throws<CommandParsingException>(() => AssertConsoleOutput("one two", "")); + } + } +} http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4a8507a1/src/tools/Lucene.Net.Tests.Cli/Commands/Benchmark/BenchmarkRunTrecEvalCommandTest.cs ---------------------------------------------------------------------- diff --git a/src/tools/Lucene.Net.Tests.Cli/Commands/Benchmark/BenchmarkRunTrecEvalCommandTest.cs b/src/tools/Lucene.Net.Tests.Cli/Commands/Benchmark/BenchmarkRunTrecEvalCommandTest.cs new file mode 100644 index 0000000..ba8a574 --- /dev/null +++ b/src/tools/Lucene.Net.Tests.Cli/Commands/Benchmark/BenchmarkRunTrecEvalCommandTest.cs @@ -0,0 +1,63 @@ +using Lucene.Net.Attributes; +using Lucene.Net.Cli.CommandLine; +using NUnit.Framework; +using System.Collections.Generic; + +namespace Lucene.Net.Cli.Commands +{ + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + public class BenchmarkRunTrecEvalCommandTest : CommandTestCase + { + protected override ConfigurationBase CreateConfiguration(MockConsoleApp app) + { + return new BenchmarkRunTrecEvalCommand.Configuration(new CommandLineOptions()) { Main = (args) => app.Main(args) }; + } + + protected override IList<Arg[]> GetOptionalArgs() + { + return new List<Arg[]>(); + } + + protected override IList<Arg[]> GetRequiredArgs() + { + // NOTE: We must order this in the sequence of the expected output. + return new List<Arg[]>() + { + new Arg[] { new Arg(inputPattern: @"C:\lucene-temp\input.txt", output: new string[] { @"C:\lucene-temp\input.txt" }) }, + new Arg[] { new Arg(inputPattern: @"C:\lucene-temp2\input.txt", output: new string[] { @"C:\lucene-temp2\input.txt" }) }, + new Arg[] { new Arg(inputPattern: @"C:\lucene-temp3\output.txt", output: new string[] { @"C:\lucene-temp3\output.txt" }) }, + new Arg[] { new Arg(inputPattern: @"C:\lucene-temp4", output: new string[] { @"C:\lucene-temp4" }) }, + }; + } + + [Test] + [LuceneNetSpecific] + public virtual void TestNotEnoughArguments() + { + AssertConsoleOutput("one two three", FromResource("NotEnoughArguments", 4)); + } + + [Test] + [LuceneNetSpecific] + public virtual void TestTooManyArguments() + { + Assert.Throws<CommandParsingException>(() => AssertConsoleOutput("one two three four five", "")); + } + } +} http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4a8507a1/src/tools/lucene-cli/Resources/Strings.Designer.cs ---------------------------------------------------------------------- diff --git a/src/tools/lucene-cli/Resources/Strings.Designer.cs b/src/tools/lucene-cli/Resources/Strings.Designer.cs index 6cbbdde..caed9b1 100644 --- a/src/tools/lucene-cli/Resources/Strings.Designer.cs +++ b/src/tools/lucene-cli/Resources/Strings.Designer.cs @@ -207,6 +207,177 @@ namespace Lucene.Net.Cli.Resources { } /// <summary> + /// Looks up a localized string similar to Utilities for benchmarking Lucene.Net.. + /// </summary> + public static string BenchmarkCommandDescription { + get { + return ResourceManager.GetString("BenchmarkCommandDescription", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to Splits Reuters SGML documents into simple text files containing: Title, Date, Dateline, Body.. + /// </summary> + public static string BenchmarkExtractReutersCommandDescription { + get { + return ResourceManager.GetString("BenchmarkExtractReutersCommandDescription", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to Path to Reuters SGML files.. + /// </summary> + public static string BenchmarkExtractReutersCommandInputDirectoryDescription { + get { + return ResourceManager.GetString("BenchmarkExtractReutersCommandInputDirectoryDescription", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to Path to a directory where the output files will be written.. + /// </summary> + public static string BenchmarkExtractReutersCommandOutputDirectoryDescription { + get { + return ResourceManager.GetString("BenchmarkExtractReutersCommandOutputDirectoryDescription", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to Extracts a downloaded Wikipedia dump into separate files for indexing.. + /// </summary> + public static string BenchmarkExtractWikipediaCommandDescription { + get { + return ResourceManager.GetString("BenchmarkExtractWikipediaCommandDescription", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to Tells the extractor to skip WIKI docs that contain only images.. + /// </summary> + public static string BenchmarkExtractWikipediaCommandDiscardImageOnlyDocsDescription { + get { + return ResourceManager.GetString("BenchmarkExtractWikipediaCommandDiscardImageOnlyDocsDescription", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to Input path to a Wikipedia XML file.. + /// </summary> + public static string BenchmarkExtractWikipediaCommandInputWikipediaFileDescription { + get { + return ResourceManager.GetString("BenchmarkExtractWikipediaCommandInputWikipediaFileDescription", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to Path to a directory where the output files will be written.. + /// </summary> + public static string BenchmarkExtractWikipediaCommandOutputDirectoryDescription { + get { + return ResourceManager.GetString("BenchmarkExtractWikipediaCommandOutputDirectoryDescription", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to Suggests quality queries based on index contents. Used for making quality test benchmarks.. + /// </summary> + public static string BenchmarkFindQualityQueriesCommandDescription { + get { + return ResourceManager.GetString("BenchmarkFindQualityQueriesCommandDescription", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to An algorithm file specifying the parameters of the benchmark to run.. + /// </summary> + public static string BenchmarkRunCommandAlgorithmFileDescription { + get { + return ResourceManager.GetString("BenchmarkRunCommandAlgorithmFileDescription", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to Runs a benchmark based on an algorithm file.. + /// </summary> + public static string BenchmarkRunCommandDescription { + get { + return ResourceManager.GetString("BenchmarkRunCommandDescription", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to Runs a TREC evaluation.. + /// </summary> + public static string BenchmarkRunTrecEvalCommandDescription { + get { + return ResourceManager.GetString("BenchmarkRunTrecEvalCommandDescription", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to Output submission file for TREC evaluation.. + /// </summary> + public static string BenchmarkRunTrecEvalCommandOutputSubmissionFileDescription { + get { + return ResourceManager.GetString("BenchmarkRunTrecEvalCommandOutputSubmissionFileDescription", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to Use description field in query.. + /// </summary> + public static string BenchmarkRunTrecEvalCommandQueryOnDescriptionDescription { + get { + return ResourceManager.GetString("BenchmarkRunTrecEvalCommandQueryOnDescriptionDescription", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to Use narrative field in query.. + /// </summary> + public static string BenchmarkRunTrecEvalCommandQueryOnNarrativeDescription { + get { + return ResourceManager.GetString("BenchmarkRunTrecEvalCommandQueryOnNarrativeDescription", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to Use title field in query. This flag will automatically be on if no other field is specified.. + /// </summary> + public static string BenchmarkRunTrecEvalCommandQueryOnTitleDescription { + get { + return ResourceManager.GetString("BenchmarkRunTrecEvalCommandQueryOnTitleDescription", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to Input file conataining relevance judgements.. + /// </summary> + public static string BenchmarkRunTrecEvalCommandQueryRelevanceFileDescription { + get { + return ResourceManager.GetString("BenchmarkRunTrecEvalCommandQueryRelevanceFileDescription", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to Input file containing queries.. + /// </summary> + public static string BenchmarkRunTrecEvalCommandTopicsFileDescription { + get { + return ResourceManager.GetString("BenchmarkRunTrecEvalCommandTopicsFileDescription", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to Sample of a performance test written programatically instead of using an algorithm file.. + /// </summary> + public static string BenchmarkSampleCommandDescription { + get { + return ResourceManager.GetString("BenchmarkSampleCommandDescription", resourceCulture); + } + } + + /// <summary> /// Looks up a localized string similar to Cross check term vectors.. /// </summary> public static string CrossCheckTermVectorsDescription { http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4a8507a1/src/tools/lucene-cli/Resources/Strings.resx ---------------------------------------------------------------------- diff --git a/src/tools/lucene-cli/Resources/Strings.resx b/src/tools/lucene-cli/Resources/Strings.resx index 4b1a488..592fe70 100644 --- a/src/tools/lucene-cli/Resources/Strings.resx +++ b/src/tools/lucene-cli/Resources/Strings.resx @@ -176,6 +176,63 @@ See this blog post (http://mentaldetritus.blogspot.com/2013/03/compiling-custom- <data name="AnalysisStempelPatchStemsCommandStemmerTableFilesEncodingDescription" xml:space="preserve"> <value>The encoding to use for the stemmer table files. If not supplied, defaults to UTF-8.</value> </data> + <data name="BenchmarkCommandDescription" xml:space="preserve"> + <value>Utilities for benchmarking Lucene.Net.</value> + </data> + <data name="BenchmarkExtractReutersCommandDescription" xml:space="preserve"> + <value>Splits Reuters SGML documents into simple text files containing: Title, Date, Dateline, Body.</value> + </data> + <data name="BenchmarkExtractReutersCommandInputDirectoryDescription" xml:space="preserve"> + <value>Path to Reuters SGML files.</value> + </data> + <data name="BenchmarkExtractReutersCommandOutputDirectoryDescription" xml:space="preserve"> + <value>Path to a directory where the output files will be written.</value> + </data> + <data name="BenchmarkExtractWikipediaCommandDescription" xml:space="preserve"> + <value>Extracts a downloaded Wikipedia dump into separate files for indexing.</value> + </data> + <data name="BenchmarkExtractWikipediaCommandDiscardImageOnlyDocsDescription" xml:space="preserve"> + <value>Tells the extractor to skip WIKI docs that contain only images.</value> + </data> + <data name="BenchmarkExtractWikipediaCommandInputWikipediaFileDescription" xml:space="preserve"> + <value>Input path to a Wikipedia XML file.</value> + </data> + <data name="BenchmarkExtractWikipediaCommandOutputDirectoryDescription" xml:space="preserve"> + <value>Path to a directory where the output files will be written.</value> + </data> + <data name="BenchmarkFindQualityQueriesCommandDescription" xml:space="preserve"> + <value>Suggests quality queries based on index contents. Used for making quality test benchmarks.</value> + </data> + <data name="BenchmarkRunCommandAlgorithmFileDescription" xml:space="preserve"> + <value>An algorithm file specifying the parameters of the benchmark to run.</value> + </data> + <data name="BenchmarkRunCommandDescription" xml:space="preserve"> + <value>Runs a benchmark based on an algorithm file.</value> + </data> + <data name="BenchmarkRunTrecEvalCommandDescription" xml:space="preserve"> + <value>Runs a TREC evaluation.</value> + </data> + <data name="BenchmarkRunTrecEvalCommandOutputSubmissionFileDescription" xml:space="preserve"> + <value>Output submission file for TREC evaluation.</value> + </data> + <data name="BenchmarkRunTrecEvalCommandQueryOnDescriptionDescription" xml:space="preserve"> + <value>Use description field in query.</value> + </data> + <data name="BenchmarkRunTrecEvalCommandQueryOnNarrativeDescription" xml:space="preserve"> + <value>Use narrative field in query.</value> + </data> + <data name="BenchmarkRunTrecEvalCommandQueryOnTitleDescription" xml:space="preserve"> + <value>Use title field in query. This flag will automatically be on if no other field is specified.</value> + </data> + <data name="BenchmarkRunTrecEvalCommandQueryRelevanceFileDescription" xml:space="preserve"> + <value>Input file conataining relevance judgements.</value> + </data> + <data name="BenchmarkRunTrecEvalCommandTopicsFileDescription" xml:space="preserve"> + <value>Input file containing queries.</value> + </data> + <data name="BenchmarkSampleCommandDescription" xml:space="preserve"> + <value>Sample of a performance test written programatically instead of using an algorithm file.</value> + </data> <data name="CrossCheckTermVectorsDescription" xml:space="preserve"> <value>Cross check term vectors.</value> </data> http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4a8507a1/src/tools/lucene-cli/commands/RootCommand.cs ---------------------------------------------------------------------- diff --git a/src/tools/lucene-cli/commands/RootCommand.cs b/src/tools/lucene-cli/commands/RootCommand.cs index c0d0b93..ff84328 100644 --- a/src/tools/lucene-cli/commands/RootCommand.cs +++ b/src/tools/lucene-cli/commands/RootCommand.cs @@ -25,10 +25,8 @@ { this.Description = FromResource("RootCommandDescription"); - //// LUCENENET TODO: Fix this to use CommandLine stuff... - //this.VersionOption("-v|--version", typeof(Program).GetTypeInfo().Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion); - this.Commands.Add(new AnalysisCommand.Configuration(options)); + this.Commands.Add(new BenchmarkCommand.Configuration(options)); this.Commands.Add(new IndexCommand.Configuration(options)); this.Commands.Add(new LockCommand.Configuration(options)); this.Commands.Add(new DemoCommand.Configuration(options)); http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4a8507a1/src/tools/lucene-cli/commands/benchmark/BenchmarkCommand.cs ---------------------------------------------------------------------- diff --git a/src/tools/lucene-cli/commands/benchmark/BenchmarkCommand.cs b/src/tools/lucene-cli/commands/benchmark/BenchmarkCommand.cs new file mode 100644 index 0000000..73a71b3 --- /dev/null +++ b/src/tools/lucene-cli/commands/benchmark/BenchmarkCommand.cs @@ -0,0 +1,51 @@ +using Lucene.Net.Benchmarks.ByTask; + +namespace Lucene.Net.Cli +{ + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + public class BenchmarkCommand : ICommand + { + public class Configuration : ConfigurationBase + { + public Configuration(CommandLineOptions options) + { + this.Main = (args) => Benchmark.Main(args); + + this.Name = "benchmark"; + this.Description = FromResource("Description"); + this.ExtendedHelpText = FromResource("ExtendedHelpText"); + + this.Commands.Add(new BenchmarkExtractReutersCommand.Configuration(options)); + this.Commands.Add(new BenchmarkExtractWikipediaCommand.Configuration(options)); + this.Commands.Add(new BenchmarkFindQualityQueriesCommand.Configuration(options)); + this.Commands.Add(new BenchmarkRunCommand.Configuration(options)); + this.Commands.Add(new BenchmarkRunTrecEvalCommand.Configuration(options)); + this.Commands.Add(new BenchmarkSampleCommand.Configuration(options)); + + this.OnExecute(() => new BenchmarkCommand().Run(this)); + } + } + + public int Run(ConfigurationBase cmd) + { + cmd.ShowHelp(); + return 1; + } + } +} http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4a8507a1/src/tools/lucene-cli/commands/benchmark/benchmark-extract-reuters/BenchmarkExtractReutersCommand.cs ---------------------------------------------------------------------- diff --git a/src/tools/lucene-cli/commands/benchmark/benchmark-extract-reuters/BenchmarkExtractReutersCommand.cs b/src/tools/lucene-cli/commands/benchmark/benchmark-extract-reuters/BenchmarkExtractReutersCommand.cs new file mode 100644 index 0000000..1cb226d --- /dev/null +++ b/src/tools/lucene-cli/commands/benchmark/benchmark-extract-reuters/BenchmarkExtractReutersCommand.cs @@ -0,0 +1,52 @@ +using Lucene.Net.Benchmarks.Utils; + +namespace Lucene.Net.Cli +{ + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + public class BenchmarkExtractReutersCommand : ICommand + { + public class Configuration : ConfigurationBase + { + public Configuration(CommandLineOptions options) + { + this.Main = (args) => ExtractReuters.Main(args); + + this.Name = "extract-reuters"; + this.Description = FromResource("Description"); + this.ExtendedHelpText = FromResource("ExtendedHelpText"); + + this.Argument("<INPUT_DIRECTORY>", FromResource("InputDirectoryDescription")); + this.Argument("<OUTPUT_DIRECTORY>", FromResource("OutputDirectoryDescription")); + + this.OnExecute(() => new BenchmarkExtractReutersCommand().Run(this)); + } + } + + public int Run(ConfigurationBase cmd) + { + if (!cmd.ValidateArguments(2)) + { + return 1; + } + + cmd.Main(cmd.GetNonNullArguments()); + return 0; + } + } +} http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4a8507a1/src/tools/lucene-cli/commands/benchmark/benchmark-extract-wikipedia/BenchmarkExtractWikipediaCommand.cs ---------------------------------------------------------------------- diff --git a/src/tools/lucene-cli/commands/benchmark/benchmark-extract-wikipedia/BenchmarkExtractWikipediaCommand.cs b/src/tools/lucene-cli/commands/benchmark/benchmark-extract-wikipedia/BenchmarkExtractWikipediaCommand.cs new file mode 100644 index 0000000..c16fc7f --- /dev/null +++ b/src/tools/lucene-cli/commands/benchmark/benchmark-extract-wikipedia/BenchmarkExtractWikipediaCommand.cs @@ -0,0 +1,72 @@ +using Lucene.Net.Benchmarks.Utils; +using Lucene.Net.Cli.CommandLine; +using System.Collections.Generic; + +namespace Lucene.Net.Cli +{ + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + public class BenchmarkExtractWikipediaCommand : ICommand + { + public class Configuration : ConfigurationBase + { + public Configuration(CommandLineOptions options) + { + this.Main = (args) => ExtractWikipedia.Main(args); + + this.Name = "extract-wikipedia"; + this.Description = FromResource("Description"); + this.ExtendedHelpText = FromResource("ExtendedHelpText"); + + this.InputWikipediaFile = this.Argument("<INPUT_WIKIPEDIA_FILE>", FromResource("InputWikipediaFileDescription")); + this.OutputDirectory = this.Argument("<OUTPUT_DIRECTORY>", FromResource("OutputDirectoryDescription")); + this.DiscardImageOnlyDocs = this.Option("-d|--discard-image-only-docs", FromResource("DiscardImageOnlyDocsDescription"), CommandOptionType.NoValue); + + this.OnExecute(() => new BenchmarkExtractWikipediaCommand().Run(this)); + } + + public CommandArgument InputWikipediaFile { get; set; } + public CommandArgument OutputDirectory { get; set; } + public CommandOption DiscardImageOnlyDocs { get; set; } + } + + public int Run(ConfigurationBase cmd) + { + if (!cmd.ValidateArguments(2)) + { + return 1; + } + + var args = new List<string>(); + var input = cmd as Configuration; + + args.Add("--input"); + args.Add(input.InputWikipediaFile.Value); + args.Add("--output"); + args.Add(input.OutputDirectory.Value); + + if (input.DiscardImageOnlyDocs.HasValue()) + { + args.Add("--discardImageOnlyDocs"); + } + + cmd.Main(args.ToArray()); + return 0; + } + } +} http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4a8507a1/src/tools/lucene-cli/commands/benchmark/benchmark-find-quality-queries/BenchmarkFindQualityQueriesCommand.cs ---------------------------------------------------------------------- diff --git a/src/tools/lucene-cli/commands/benchmark/benchmark-find-quality-queries/BenchmarkFindQualityQueriesCommand.cs b/src/tools/lucene-cli/commands/benchmark/benchmark-find-quality-queries/BenchmarkFindQualityQueriesCommand.cs new file mode 100644 index 0000000..81ad29b --- /dev/null +++ b/src/tools/lucene-cli/commands/benchmark/benchmark-find-quality-queries/BenchmarkFindQualityQueriesCommand.cs @@ -0,0 +1,51 @@ +using Lucene.Net.Benchmarks.Quality.Trec; + +namespace Lucene.Net.Cli +{ + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + public class BenchmarkFindQualityQueriesCommand : ICommand + { + public class Configuration : ConfigurationBase + { + public Configuration(CommandLineOptions options) + { + this.Main = (args) => QueryDriver.Main(args); + + this.Name = "find-quality-queries"; + this.Description = FromResource("Description"); + this.ExtendedHelpText = FromResource("ExtendedHelpText"); + + this.Arguments.Add(new IndexDirectoryArgument(required: false)); + + this.OnExecute(() => new BenchmarkFindQualityQueriesCommand().Run(this)); + } + } + + public int Run(ConfigurationBase cmd) + { + if (!cmd.ValidateArguments(1)) + { + return 1; + } + + cmd.Main(cmd.GetNonNullArguments()); + return 0; + } + } +} http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4a8507a1/src/tools/lucene-cli/commands/benchmark/benchmark-run-trec-eval/BenchmarkRunTrecEvalCommand.cs ---------------------------------------------------------------------- diff --git a/src/tools/lucene-cli/commands/benchmark/benchmark-run-trec-eval/BenchmarkRunTrecEvalCommand.cs b/src/tools/lucene-cli/commands/benchmark/benchmark-run-trec-eval/BenchmarkRunTrecEvalCommand.cs new file mode 100644 index 0000000..0d64231 --- /dev/null +++ b/src/tools/lucene-cli/commands/benchmark/benchmark-run-trec-eval/BenchmarkRunTrecEvalCommand.cs @@ -0,0 +1,78 @@ +using Lucene.Net.Benchmarks.Quality.Trec; +using Lucene.Net.Cli.CommandLine; +using System.Collections.Generic; + +namespace Lucene.Net.Cli +{ + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + public class BenchmarkRunTrecEvalCommand : ICommand + { + public class Configuration : ConfigurationBase + { + public Configuration(CommandLineOptions options) + { + this.Main = (args) => QueryDriver.Main(args); + + this.Name = "run-trec-eval"; + this.Description = FromResource("Description"); + this.ExtendedHelpText = FromResource("ExtendedHelpText"); + + this.Argument("<INPUT_TOPICS_FILE>", FromResource("TopicsFileDescription")); + this.Argument("<INPUT_QUERY_RELEVANCE_FILE>", FromResource("QueryRelevanceFileDescription")); + this.Argument("<OUTPUT_SUBMISSION_FILE>", FromResource("OutputSubmissionFileDescription")); + this.Arguments.Add(new IndexDirectoryArgument(required: true)); + this.QueryOnTitle = this.Option("-t|--query-on-title", FromResource("QueryOnTitleDescription"), CommandOptionType.NoValue); + this.QueryOnDescription = this.Option("-d|--query-on-description", FromResource("QueryOnDescriptionDescription"), CommandOptionType.NoValue); + this.QueryOnNarrative = this.Option("-n|--query-on-narrative", FromResource("QueryOnNarrativeDescription"), CommandOptionType.NoValue); + + this.OnExecute(() => new BenchmarkRunTrecEvalCommand().Run(this)); + } + + public CommandOption QueryOnTitle { get; set; } + public CommandOption QueryOnDescription { get; set; } + public CommandOption QueryOnNarrative { get; set; } + } + + public int Run(ConfigurationBase cmd) + { + if (!cmd.ValidateArguments(4)) + { + return 1; + } + + var input = cmd as Configuration; + var args = new List<string>(cmd.GetNonNullArguments()); + + string querySpec = string.Empty; + + if (input.QueryOnTitle.HasValue()) + querySpec += "T"; + if (input.QueryOnDescription.HasValue()) + querySpec += "D"; + if (input.QueryOnNarrative.HasValue()) + querySpec += "N"; + + if (!string.IsNullOrEmpty(querySpec)) + args.Add(querySpec); + + cmd.Main(args.ToArray()); + return 0; + } + } +} http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4a8507a1/src/tools/lucene-cli/commands/benchmark/benchmark-run/BenchmarkRunCommand.cs ---------------------------------------------------------------------- diff --git a/src/tools/lucene-cli/commands/benchmark/benchmark-run/BenchmarkRunCommand.cs b/src/tools/lucene-cli/commands/benchmark/benchmark-run/BenchmarkRunCommand.cs new file mode 100644 index 0000000..4f29f6f --- /dev/null +++ b/src/tools/lucene-cli/commands/benchmark/benchmark-run/BenchmarkRunCommand.cs @@ -0,0 +1,50 @@ +using Lucene.Net.Benchmarks.ByTask; + +namespace Lucene.Net.Cli +{ + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + public class BenchmarkRunCommand : ICommand + { + public class Configuration : ConfigurationBase + { + public Configuration(CommandLineOptions options) + { + this.Main = (args) => Benchmark.Main(args); + + this.Name = "run"; + this.Description = FromResource("Description"); + this.ExtendedHelpText = FromResource("ExtendedHelpText"); + this.Argument("<ALGORITHM_FILE>", FromResource("AlgorithmFileDescription")); + + this.OnExecute(() => new BenchmarkRunCommand().Run(this)); + } + } + + public int Run(ConfigurationBase cmd) + { + if (!cmd.ValidateArguments(1)) + { + return 1; + } + + cmd.Main(cmd.GetNonNullArguments()); + return 0; + } + } +} http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4a8507a1/src/tools/lucene-cli/commands/benchmark/benchmark-sample/BenchmarkSampleCommand.cs ---------------------------------------------------------------------- diff --git a/src/tools/lucene-cli/commands/benchmark/benchmark-sample/BenchmarkSampleCommand.cs b/src/tools/lucene-cli/commands/benchmark/benchmark-sample/BenchmarkSampleCommand.cs new file mode 100644 index 0000000..c8a3490 --- /dev/null +++ b/src/tools/lucene-cli/commands/benchmark/benchmark-sample/BenchmarkSampleCommand.cs @@ -0,0 +1,53 @@ +using Lucene.Net.Benchmarks.ByTask.Programmatic; +using System.Collections.Generic; + +namespace Lucene.Net.Cli +{ + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + public class BenchmarkSampleCommand : ICommand + { + public class Configuration : DemoConfiguration + { + public Configuration(CommandLineOptions options) + { + this.Main = (args) => Sample.Main(args); + + this.Name = "sample"; + this.Description = FromResource("Description"); + this.ExtendedHelpText = FromResource("ExtendedHelpText"); + + this.OnExecute(() => new BenchmarkSampleCommand().Run(this)); + } + + public override IEnumerable<string> SourceCodeFiles + { + get + { + return new string[] { "Sample.cs" }; + } + } + } + + public int Run(ConfigurationBase cmd) + { + cmd.Main(new string[0]); + return 0; + } + } +} http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4a8507a1/src/tools/lucene-cli/commands/demo/DemoConfiguration.cs ---------------------------------------------------------------------- diff --git a/src/tools/lucene-cli/commands/demo/DemoConfiguration.cs b/src/tools/lucene-cli/commands/demo/DemoConfiguration.cs index d1f4eda..b2592c3 100644 --- a/src/tools/lucene-cli/commands/demo/DemoConfiguration.cs +++ b/src/tools/lucene-cli/commands/demo/DemoConfiguration.cs @@ -30,6 +30,7 @@ namespace Lucene.Net.Cli protected DemoConfiguration() { + this.viewSourceOption = this.Option( "-src|--view-source-code", Resources.Strings.ViewSourceCodeDescription, http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4a8507a1/src/tools/lucene-cli/docs/benchmark/extract-reuters.md ---------------------------------------------------------------------- diff --git a/src/tools/lucene-cli/docs/benchmark/extract-reuters.md b/src/tools/lucene-cli/docs/benchmark/extract-reuters.md new file mode 100644 index 0000000..d63b2d3 --- /dev/null +++ b/src/tools/lucene-cli/docs/benchmark/extract-reuters.md @@ -0,0 +1,31 @@ +# extract-reuters + +### Name + +`benchmark-extract-reuters` - Splits Reuters SGML documents into simple text files containing: Title, Date, Dateline, Body. + +### Synopsis + +<code>dotnet lucene-cli.dll benchmark extract-reuters [?|-h|--help]</code> + +### Arguments + +`INPUT_DIRECTORY` + +Path to Reuters SGML files. + +`OUTPUT_DIRECTORY` + +Path to a directory where the output files will be written. + +### Options + +`?|-h|--help` + +Prints out a short help for the command. + +### Example + +Extracts the reuters SGML files in the `z:\input` directory and places the content in the `z:\output` directory. + +<code>dotnet lucene-cli.dll benchmark extract-reuters z:\input z:\output</code> http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4a8507a1/src/tools/lucene-cli/docs/benchmark/extract-wikipedia.md ---------------------------------------------------------------------- diff --git a/src/tools/lucene-cli/docs/benchmark/extract-wikipedia.md b/src/tools/lucene-cli/docs/benchmark/extract-wikipedia.md new file mode 100644 index 0000000..1d48911 --- /dev/null +++ b/src/tools/lucene-cli/docs/benchmark/extract-wikipedia.md @@ -0,0 +1,35 @@ +# extract-wikipedia + +### Name + +`benchmark-extract-wikipedia` - Extracts a downloaded Wikipedia dump into separate files for indexing. + +### Synopsis + +<code>dotnet lucene-cli.dll benchmark extract-wikipedia [?|-h|--help]</code> + +### Arguments + +`INPUT_WIKIPEDIA_FILE` + +Input path to a Wikipedia XML file. + +`OUTPUT_DIRECTORY` + +Path to a directory where the output files will be written. + +### Options + +`?|-h|--help` + +Prints out a short help for the command. + +`-d|--discard-image-only-docs` + +Tells the extractor to skip WIKI docs that contain only images. + +### Example + +Extracts the `c:\wiki.xml` file into the `c:\out` directory, skipping any docs that only contain images. + +<code>dotnet lucene-cli.dll benchmark extract-wikipedia c:\wiki.xml c:\out -d</code> http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4a8507a1/src/tools/lucene-cli/docs/benchmark/find-quality-queries.md ---------------------------------------------------------------------- diff --git a/src/tools/lucene-cli/docs/benchmark/find-quality-queries.md b/src/tools/lucene-cli/docs/benchmark/find-quality-queries.md new file mode 100644 index 0000000..c4e615b --- /dev/null +++ b/src/tools/lucene-cli/docs/benchmark/find-quality-queries.md @@ -0,0 +1,27 @@ +# find-quality-queries + +### Name + +`benchmark-find-quality-queries` - Suggests quality queries based on index contents. Used for making quality test benchmarks. + +### Synopsis + +<code>dotnet lucene-cli.dll benchmark find-quality-queries [?|-h|--help]</code> + +### Arguments + +`INDEX_DIRECTORY` + +Path to the index. + +### Options + +`?|-h|--help` + +Prints out a short help for the command. + +### Example + +Finds quality queries on the `c:\lucene-index` index directory. + +<code>dotnet lucene-cli.dll benchmark find-quality-queries c:\lucene-index</code> http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4a8507a1/src/tools/lucene-cli/docs/benchmark/index.md ---------------------------------------------------------------------- diff --git a/src/tools/lucene-cli/docs/benchmark/index.md b/src/tools/lucene-cli/docs/benchmark/index.md new file mode 100644 index 0000000..66d4e04 --- /dev/null +++ b/src/tools/lucene-cli/docs/benchmark/index.md @@ -0,0 +1,14 @@ +# benchmark + +## Description + +Utilities for benchmarking Lucene.Net. + +## Commands + +- [extract-reuters](extract-reuters.md) +- [extract-wikipedia](extract-wikipedia.md) +- [find-quality-queries](find-quality-queries.md) +- [run](run.md) +- [run-trec-eval](run-trec-eval.md) +- [sample](sample.md) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4a8507a1/src/tools/lucene-cli/docs/benchmark/run-trec-eval.md ---------------------------------------------------------------------- diff --git a/src/tools/lucene-cli/docs/benchmark/run-trec-eval.md b/src/tools/lucene-cli/docs/benchmark/run-trec-eval.md new file mode 100644 index 0000000..5d5960b --- /dev/null +++ b/src/tools/lucene-cli/docs/benchmark/run-trec-eval.md @@ -0,0 +1,51 @@ +# run-trec-eval + +### Name + +`benchmark-run-trec-eval` - Runs a TREC evaluation. + +### Synopsis + +<code>dotnet lucene-cli.dll benchmark run-trec-eval [?|-h|--help]</code> + +### Arguments + +`INPUT_TOPICS_FILE` + +Input file containing queries. + +`INPUT_QUERY_RELEVANCE_FILE` + +Input file conataining relevance judgements. + +`OUTPUT_SUBMISSION_FILE` + +Output submission file for TREC evaluation. + +`INDEX_DIRECTORY` + +The index directory. + +### Options + +`?|-h|--help` + +Prints out a short help for the command. + +`-t|--query-on-title` + +Use title field in query. This flag will automatically be on if no other field is specified. + +`-d|--query-on-description` + +Use description field in query. + +`-n|--query-on-narrative` + +Use narrative field in query. + +### Example + +Runs a TREC evaluation on the `c:\topics` queries file and the `c:\queries` relevance judgements on the `c:\lucene-index` index using the description and narrative fields and places the output in `c:\output.txt`. + +<code>dotnet lucene-cli.dll benchmark run-trec-eval c:\topics.txt c:\queries.txt c:\submissions.txt c:\output.txt c:\lucene-index -d -n</code> http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4a8507a1/src/tools/lucene-cli/docs/benchmark/run.md ---------------------------------------------------------------------- diff --git a/src/tools/lucene-cli/docs/benchmark/run.md b/src/tools/lucene-cli/docs/benchmark/run.md new file mode 100644 index 0000000..8042307 --- /dev/null +++ b/src/tools/lucene-cli/docs/benchmark/run.md @@ -0,0 +1,31 @@ +# run + +### Name + +`benchmark-run` - Runs a benchmark based on an algorithm file. + +### Synopsis + +<code>dotnet lucene-cli.dll benchmark run [?|-h|--help]</code> + +### Arguments + +`ALGORITHM_FILE` + +An algorithm file specifying the parameters of the benchmark to run. + +`OUTPUT_DIRECTORY` + +Path to a directory where the output files will be written. + +### Options + +`?|-h|--help` + +Prints out a short help for the command. + +### Example + +Runs a benchmark on the `c:\check.alg` algorithm file. + +<code>dotnet lucene-cli.dll benchmark run c:\check.alg</code> http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4a8507a1/src/tools/lucene-cli/docs/benchmark/sample.md ---------------------------------------------------------------------- diff --git a/src/tools/lucene-cli/docs/benchmark/sample.md b/src/tools/lucene-cli/docs/benchmark/sample.md new file mode 100644 index 0000000..7245af5 --- /dev/null +++ b/src/tools/lucene-cli/docs/benchmark/sample.md @@ -0,0 +1,29 @@ +# sample + +### Name + +`benchmark-sample` - Sample of a performance test written programatically instead of using an algorithm file. + +### Synopsis + +<code>dotnet lucene-cli.dll benchmark sample [-src|--view-source-code] [-out|--output-source-code] [?|-h|--help]</code> + +### Options + +`?|-h|--help` + +Prints out a short help for the command. + +`-src|--view-source-code` + +Prints the source code to the console. Use `SPACE` or `n` to move to the next page of text, `ENTER` to scroll to the next line of text, `q` or `x` to quit. + +`-out|--output-source-code <DIRECTORY>` + +Outputs the source code to the specified directory. + +### Example + +Runs the sample. + +<code>dotnet lucene-cli.dll benchmark sample</code> http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4a8507a1/src/tools/lucene-cli/project.json ---------------------------------------------------------------------- diff --git a/src/tools/lucene-cli/project.json b/src/tools/lucene-cli/project.json index 767a705..a33bdb4 100644 --- a/src/tools/lucene-cli/project.json +++ b/src/tools/lucene-cli/project.json @@ -10,6 +10,7 @@ }, "embed": { "include": [ + "../../Lucene.Net.Benchmark/ByTask/Programmatic/Sample.cs", "../../Lucene.Net.Demo/*.cs", "../../Lucene.Net.Demo/Facet/*.cs" ] @@ -21,6 +22,7 @@ "Lucene.Net.Analysis.Common": "4.8.0", "Lucene.Net.Analysis.Kuromoji": "4.8.0", "Lucene.Net.Analysis.Stempel": "4.8.0", + "Lucene.Net.Benchmark": "4.8.0", "Lucene.Net.Demo": "4.8.0", "Lucene.Net.Expressions": "4.8.0", "Lucene.Net.Facet": "4.8.0",