Skip to content

Commit 3efcb44

Browse files
committed
rename BenchmarkApp -> Benchmark
1 parent cf8db80 commit 3efcb44

6 files changed

Lines changed: 238 additions & 0 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
set(SAMPLE_NAME "Benchmark")
2+
3+
set(LOCAL_SRCS "")
4+
aux_source_directory(src LOCAL_SRCS)
5+
6+
add_executable( ${SAMPLE_NAME} ${LOCAL_SRCS} )
7+
#set_target_properties( ${SAMPLE_NAME} PROPERTIES COMPILE_FLAGS ${RELEASE_CXX_FLAGS} )
8+
target_link_libraries( ${SAMPLE_NAME} PocoJSON PocoFoundation )

‎JSON/samples/Benchmark/Makefile‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#
2+
# Makefile
3+
#
4+
# $Id$
5+
#
6+
# Makefile for Poco JSON Benchmark
7+
#
8+
9+
include $(POCO_BASE)/build/rules/global
10+
11+
objects = Benchmark
12+
13+
target = Benchmark
14+
target_version = 1
15+
target_libs = PocoJSON PocoFoundation
16+
17+
include $(POCO_BASE)/build/rules/exec

‎JSON/samples/Benchmark/input‎

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
{"web-app": {
2+
"servlet": [
3+
{
4+
"servlet-name": "cofaxCDS",
5+
"servlet-class": "org.cofax.cds.CDSServlet",
6+
"init-param": {
7+
"configGlossary:installationAt": "Philadelphia, PA",
8+
"configGlossary:adminEmail": "ksm@pobox.com",
9+
"configGlossary:poweredBy": "Cofax",
10+
"configGlossary:poweredByIcon": "/images/cofax.gif",
11+
"configGlossary:staticPath": "/content/static",
12+
"templateProcessorClass": "org.cofax.WysiwygTemplate",
13+
"templateLoaderClass": "org.cofax.FilesTemplateLoader",
14+
"templatePath": "templates",
15+
"templateOverridePath": "",
16+
"defaultListTemplate": "listTemplate.htm",
17+
"defaultFileTemplate": "articleTemplate.htm",
18+
"useJSP": false,
19+
"jspListTemplate": "listTemplate.jsp",
20+
"jspFileTemplate": "articleTemplate.jsp",
21+
"cachePackageTagsTrack": 200,
22+
"cachePackageTagsStore": 200,
23+
"cachePackageTagsRefresh": 60,
24+
"cacheTemplatesTrack": 100,
25+
"cacheTemplatesStore": 50,
26+
"cacheTemplatesRefresh": 15,
27+
"cachePagesTrack": 200,
28+
"cachePagesStore": 100,
29+
"cachePagesRefresh": 10,
30+
"cachePagesDirtyRead": 10,
31+
"searchEngineListTemplate": "forSearchEnginesList.htm",
32+
"searchEngineFileTemplate": "forSearchEngines.htm",
33+
"searchEngineRobotsDb": "WEB-INF/robots.db",
34+
"useDataStore": true,
35+
"dataStoreClass": "org.cofax.SqlDataStore",
36+
"redirectionClass": "org.cofax.SqlRedirection",
37+
"dataStoreName": "cofax",
38+
"dataStoreDriver": "com.microsoft.jdbc.sqlserver.SQLServerDriver",
39+
"dataStoreUrl": "jdbc:microsoft:sqlserver://LOCALHOST:1433;DatabaseName=goon",
40+
"dataStoreUser": "sa",
41+
"dataStorePassword": "dataStoreTestQuery",
42+
"dataStoreTestQuery": "SET NOCOUNT ON;select test='test';",
43+
"dataStoreLogFile": "/usr/local/tomcat/logs/datastore.log",
44+
"dataStoreInitConns": 10,
45+
"dataStoreMaxConns": 100,
46+
"dataStoreConnUsageLimit": 100,
47+
"dataStoreLogLevel": "debug",
48+
"maxUrlLength": 500}},
49+
{
50+
"servlet-name": "cofaxEmail",
51+
"servlet-class": "org.cofax.cds.EmailServlet",
52+
"init-param": {
53+
"mailHost": "mail1",
54+
"mailHostOverride": "mail2"}},
55+
{
56+
"servlet-name": "cofaxAdmin",
57+
"servlet-class": "org.cofax.cds.AdminServlet"},
58+
59+
{
60+
"servlet-name": "fileServlet",
61+
"servlet-class": "org.cofax.cds.FileServlet"},
62+
{
63+
"servlet-name": "cofaxTools",
64+
"servlet-class": "org.cofax.cms.CofaxToolsServlet",
65+
"init-param": {
66+
"templatePath": "toolstemplates/",
67+
"log": 1,
68+
"logLocation": "/usr/local/tomcat/logs/CofaxTools.log",
69+
"logMaxSize": "",
70+
"dataLog": 1,
71+
"dataLogLocation": "/usr/local/tomcat/logs/dataLog.log",
72+
"dataLogMaxSize": "",
73+
"removePageCache": "/content/admin/remove?cache=pages&id=",
74+
"removeTemplateCache": "/content/admin/remove?cache=templates&id=",
75+
"fileTransferFolder": "/usr/local/tomcat/webapps/content/fileTransferFolder",
76+
"lookInContext": 1,
77+
"adminGroupID": 4,
78+
"betaServer": true}}],
79+
"servlet-mapping": {
80+
"cofaxCDS": "/",
81+
"cofaxEmail": "/cofaxutil/aemail/*",
82+
"cofaxAdmin": "/admin/*",
83+
"fileServlet": "/static/*",
84+
"cofaxTools": "/tools/*"},
85+
86+
"taglib": {
87+
"taglib-uri": "cofax.tld",
88+
"taglib-location": "/WEB-INF/tlds/cofax.tld"}}}
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
//
2+
// Benchmark.cpp
3+
//
4+
// $Id$
5+
//
6+
// This sample shows a benchmark of the JSON parser.
7+
//
8+
// Copyright (c) 2004-2012, Applied Informatics Software Engineering GmbH.
9+
// and Contributors.
10+
//
11+
// Permission is hereby granted, free of charge, to any person or organization
12+
// obtaining a copy of the software and accompanying documentation covered by
13+
// this license (the "Software") to use, reproduce, display, distribute,
14+
// execute, and transmit the Software, and to prepare derivative works of the
15+
// Software, and to permit third-parties to whom the Software is furnished to
16+
// do so, all subject to the following:
17+
//
18+
// The copyright notices in the Software and this entire statement, including
19+
// the above license grant, this restriction and the following disclaimer,
20+
// must be included in all copies of the Software, in whole or in part, and
21+
// all derivative works of the Software, unless such copies or derivative
22+
// works are solely in the form of machine-executable object code generated by
23+
// a source language processor.
24+
//
25+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27+
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
28+
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
29+
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
30+
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
31+
// DEALINGS IN THE SOFTWARE.
32+
//
33+
34+
#include "Poco/Timestamp.h"
35+
#include "Poco/JSON/Parser.h"
36+
#include "Poco/JSON/DefaultHandler.h"
37+
#include "Poco/JSON/JSONException.h"
38+
#include "Poco/Environment.h"
39+
#include "Poco/Path.h"
40+
#include "Poco/File.h"
41+
#include "Poco/FileStream.h"
42+
#include "Poco/StreamCopier.h"
43+
44+
#include <iostream>
45+
#include <iomanip>
46+
47+
void printTimeDiff(const Poco::Timestamp& start, const Poco::Timestamp& end)
48+
{
49+
Poco::Timestamp::TimeDiff diff = end - start;
50+
std::cout << std::setw(25) << std::left << diff;
51+
}
52+
53+
int main(int argc, char** argv)
54+
{
55+
Poco::JSON::Object::Ptr obj;
56+
57+
std::string dir = Poco::Environment::get("POCO_BASE") + "/JSON/samples/Benchmark/";
58+
Poco::Path filePath(dir, "input");
59+
60+
std::ostringstream ostr;
61+
62+
if ( filePath.isFile() )
63+
{
64+
Poco::File inputFile(filePath);
65+
if ( inputFile.exists() )
66+
{
67+
Poco::FileInputStream fis(filePath.toString());
68+
Poco::StreamCopier::copyStream(fis, ostr);
69+
}
70+
else
71+
{
72+
std::cout << filePath.toString() << " doesn't exist!" << std::endl;
73+
return 1;
74+
}
75+
}
76+
77+
std::cout << std::setw(25) << "POCO JSON";
78+
79+
std::string jsonStr = ostr.str();
80+
81+
try
82+
{
83+
Poco::JSON::DefaultHandler handler;
84+
Poco::JSON::Parser parser;
85+
parser.setHandler(&handler);
86+
Poco::Timestamp time1;
87+
parser.parse(jsonStr);
88+
Poco::DynamicAny result = handler.result();
89+
Poco::Timestamp time2;
90+
printTimeDiff(time1, time2);
91+
92+
if ( result.type() == typeid(Poco::JSON::Object::Ptr) )
93+
{
94+
obj = result.extract<Poco::JSON::Object::Ptr>();
95+
}
96+
97+
//Serialize to string
98+
std::ostringstream out;
99+
Poco::Timestamp time3;
100+
obj->stringify(out);
101+
Poco::Timestamp time4;
102+
printTimeDiff(time3, time4);
103+
std::cout << std::endl;
104+
}
105+
catch(Poco::JSON::JSONException jsone)
106+
{
107+
std::cout << jsone.message() << std::endl;
108+
}
109+
110+
return 0;
111+
}

‎JSON/samples/CMakeLists.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add_subdirectory( Benchmark )

‎JSON/samples/Makefile‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#
2+
# Makefile
3+
#
4+
# $Id$
5+
#
6+
# Makefile for Poco JSON Samples
7+
#
8+
9+
.PHONY: projects
10+
clean all: projects
11+
projects:
12+
$(MAKE) -C Benchmark $(MAKECMDGOALS)
13+

0 commit comments

Comments
 (0)