Skip to content

Commit

Permalink
the benchdb library works now, and is callable from C/C++
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Samuelsson committed Nov 25, 2011
1 parent 13e6126 commit bea840b
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 64 deletions.
17 changes: 14 additions & 3 deletions tests/Benchmarks/linpack/mosync/.mosyncproject
Expand Up @@ -3,17 +3,28 @@
<build.cfg id="Debug" types="Debug"/>
<build.cfg id="Release" types="Release"/>
<properties>
<property key="build.prefs:additional.include.paths/Debug" value=""/>
<property key="build.prefs:additional.include.paths/Release" value=""/>
<property key="build.prefs:additional.libraries/Debug" value="MAUtilD.lib"/>
<property key="build.prefs:additional.libraries/Release" value="MAUtil.lib"/>
<property key="build.prefs:additional.library.paths/Release" value=""/>
<property key="build.prefs:additional.library.paths/Debug" value=""/>
<property key="build.prefs:additional.library.paths/Release" value="C:/Mosync/lib/benchdb"/>
<property key="build.prefs:extra.link.sw/Debug" value=""/>
<property key="build.prefs:extra.link.sw/Release" value=""/>
<property key="build.prefs:extra.res.sw/Debug" value=""/>
<property key="build.prefs:extra.res.sw/Release" value=""/>
<property key="build.prefs:gcc.warnings/Debug" value="0"/>
<property key="build.prefs:gcc.warnings/Release" value="0"/>
<property key="build.prefs:ignore.default.libraries/Release" value="false"/>
<property key="build.prefs:lib.output.path/Release" value="Release/benchdb.lib"/>
<property key="build.prefs:memory.data/Release" value="1024"/>
<property key="build.prefs:memory.heap/Release" value="512"/>
<property key="build.prefs:project.type" value=""/>
<property key="build.prefs:project.type" value="lib"/>
<property key="dependency.strategy" value="0"/>
<property key="excludes/Release" value=""/>
<property key="excludes/Debug" value="linpack.c"/>
<property key="excludes/Release" value="linpack.c"/>
<property key="symbian.uids:uid.s60v2uid" value="0x042db65a"/>
<property key="symbian.uids:uid.s60v3uid" value="0xe811792f"/>
<property key="template.id" value="project.c"/>
</properties>
</project>
158 changes: 101 additions & 57 deletions tests/Benchmarks/linpack/mosync/benchdb.cpp
Expand Up @@ -14,16 +14,16 @@
class ConnectionMoblet : public MAUtil::Moblet, private MAUtil::HttpConnectionListener
{
public:
ConnectionMoblet(char * completeUrl);
ConnectionMoblet(char * completeUrl);

void httpFinished(MAUtil::HttpConnection *conn, int result);
void connRecvFinished(MAUtil::Connection *conn, int result);
void connReadFinished(MAUtil::Connection *conn, int result);
void initiateConnection(const char* url);
void httpFinished(MAUtil::HttpConnection *conn, int result);
void connRecvFinished(MAUtil::Connection *conn, int result);
void connReadFinished(MAUtil::Connection *conn, int result);
void initiateConnection(const char* url);
private:
char mBuffer[CONNECTION_BUFFER_SIZE];
MAUtil::HttpConnection mHttp;
bool mIsConnected;
char mBuffer[CONNECTION_BUFFER_SIZE];
MAUtil::HttpConnection mHttp;
bool mIsConnected;
};
ConnectionMoblet::ConnectionMoblet(char * completeUrl) : mHttp(this) //constructor, taking the complete url of the publish_script as an arg
, mIsConnected(false)
Expand All @@ -34,63 +34,63 @@ ConnectionMoblet::ConnectionMoblet(char * completeUrl) : mHttp(this) //construct
}
// connect to the given url if not other connection is active
void ConnectionMoblet::initiateConnection(const char* url) {
if(mIsConnected) {
printf("already connected\n..");
return;
}
printf("\nconnecting to %s", url);

int res = mHttp.create(url, HTTP_GET); //we publish using HTTP GET
if(res < 0) {
printf("unable to connect - %i\n", res);
} else {
mHttp.finish();
mIsConnected = true;
}
if(mIsConnected) {
printf("already connected\n..");
return;
}
printf("\nconnecting to %s", url);

int res = mHttp.create(url, HTTP_GET); //we publish using HTTP GET
if(res < 0) {
printf("unable to connect - %i\n", res);
} else {
mHttp.finish();
mIsConnected = true;
}
}
void ConnectionMoblet::httpFinished(MAUtil::HttpConnection* http, int result) {
printf("HTTP %i\n", result);

MAUtil::String contentLengthStr;
int responseBytes = mHttp.getResponseHeader("content-length", &contentLengthStr);
int contentLength = 0;
if(responseBytes == CONNERR_NOHEADER)
printf("no content-length response header\n");
else {
printf("content-length : %s\n", contentLengthStr.c_str());
contentLength = atoi(contentLengthStr.c_str());
}
if(contentLength >= CONNECTION_BUFFER_SIZE || contentLength == 0) {
printf("Receive in chunks..\n");
mHttp.recv(mBuffer, CONNECTION_BUFFER_SIZE);
} else {
mBuffer[contentLength] = 0;
mHttp.read(mBuffer, contentLength);
}
printf("HTTP %i\n", result);

MAUtil::String contentLengthStr;
int responseBytes = mHttp.getResponseHeader("content-length", &contentLengthStr);
int contentLength = 0;
if(responseBytes == CONNERR_NOHEADER)
printf("no content-length response header\n");
else {
printf("content-length : %s\n", contentLengthStr.c_str());
contentLength = atoi(contentLengthStr.c_str());
}
if(contentLength >= CONNECTION_BUFFER_SIZE || contentLength == 0) {
printf("Receive in chunks..\n");
mHttp.recv(mBuffer, CONNECTION_BUFFER_SIZE);
} else {
mBuffer[contentLength] = 0;
mHttp.read(mBuffer, contentLength);
}

}
void ConnectionMoblet::connReadFinished(MAUtil::Connection* conn, int result) {
if(result >= 0)
printf("connReadFinished %i\n", result);
else
printf("connection error %i\n", result);
mHttp.close();
if(result >= 0)
printf("connReadFinished %i\n", result);
else
printf("connection error %i\n", result);
mHttp.close();

mIsConnected = false;
mIsConnected = false;
}
void ConnectionMoblet::connRecvFinished(MAUtil::Connection * conn, int result){
if(result >= 0) {
printf("connRecvFinished %i\n", result);
mHttp.recv(mBuffer, CONNECTION_BUFFER_SIZE);
return;
}
else if(result == CONNERR_CLOSED) {
printf("Receive finished!\n");
} else {
printf("connection error %i\n", result);
}
mHttp.close();
mIsConnected = false;
if(result >= 0) {
printf("connRecvFinished %i\n", result);
mHttp.recv(mBuffer, CONNECTION_BUFFER_SIZE);
return;
}
else if(result == CONNERR_CLOSED) {
printf("Receive finished!\n");
} else {
printf("connection error %i\n", result);
}
mHttp.close();
mIsConnected = false;
}

extern "C" int publish_linpack_result(char * url, char * revision, char * runtime, char * git_hash, char * phone, char * native_sdk_ver, float mflops) {
Expand All @@ -110,3 +110,47 @@ extern "C" int publish_linpack_result(char * url, char * revision, char * runtim

}

extern "C" int publish_opengl_result(char * url, char * revision, char * runtime, char * git_hash, char * phone, char * native_sdk_ver, int test1, int test2, int test3, int test4) {

InitConsole();
gConsoleLogging = 1;

//need to use sprintf to build the url and pass it to the constructor, then we will be all set!
char complete_url[200]; //build and store our url here
/* building the url using sprintf */
sprintf(complete_url, "%s%s%s%s%s%s%s%s%s%s%s%s%d%s%d%s%d%s%d", url, "?benchmark=linpack&revision=", revision, "&runtime=", runtime, "&git_hash=", git_hash, "&phone=", phone, "&native_sdk_ver=", native_sdk_ver, "&test1=", test1, "&test2=", test2, "&test3=", test3, "&test4=", test4);

ConnectionMoblet * cm = new ConnectionMoblet(complete_url); //pass the url to the ConnectionMoblet
MAUtil::Moblet::run(cm); //run it
delete cm;
return 0;

}

extern "C" int publish_membench_result(char * url, char * revision, char * runtime, char * git_hash, char * phone,
char * native_sdk_ver, float alloc_str_10, float alloc_str_100, float alloc_void_1, float alloc_void_100,
float alloc_void_1000, float alloc_dummy, float alloc_dummy_struct, float alloc_dummy_mix,
float access_array, float access_vector, float add_vector, float access_dummy, float access_dummy_struct,
float access_dummy_mix) {

InitConsole();
gConsoleLogging = 1;

//need to use sprintf to build the url and pass it to the constructor, then we will be all set!
char complete_url[1000]; //build and store our url here
/* building the url using sprintf TODO fix all parameters (if the sprintf-call is set up wrong we will get data oob in the caller of this lib function) */
sprintf(complete_url, "%s%s%s%s%s%s%s%s%s%s%s%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f", url, "?benchmark=membench&revision=", revision, "&runtime=", runtime, "&git_hash=",
git_hash, "&phone=", phone, "&native_sdk_ver=", native_sdk_ver, "&alloc_str_10=", alloc_str_10, "&alloc_str_100=", alloc_str_100,
"&alloc_void_1=", alloc_void_1, "&alloc_void_100=", alloc_void_100, "&alloc_void_1000=", alloc_void_1000,
"&alloc_dummy=", alloc_dummy, "&alloc_dummy_struct=", alloc_dummy_struct, "&alloc_dummy_mix=", alloc_dummy_mix, "&access_array=", access_array,
"&access_vector=", access_vector, "&add_vector=", add_vector, "&access_dummy=", access_dummy,
"&access_dummy_struct=", access_dummy_struct, "&access_dummy_mix=", access_dummy_mix);

ConnectionMoblet * cm = new ConnectionMoblet(complete_url); //pass the url to the ConnectionMoblet
MAUtil::Moblet::run(cm); //run it
delete cm;
return 0;

}


18 changes: 17 additions & 1 deletion tests/Benchmarks/linpack/mosync/benchdb.h
Expand Up @@ -8,8 +8,24 @@
#ifndef BENCHDB_H_
#define BENCHDB_H_

#ifdef __cplusplus
extern "C" {
#endif

int publish_linpack_result(char * url, char * revision, char * runtime, char * git_hash, char * phone, char * native_sdk_ver, float mflops);
int publish_linpack_result(char * url, char * revision, char * runtime, char * git_hash, char * phone,
char * native_sdk_ver, float mflops);

int publish_opengl_result(char * url, char * revision, char * runtime, char * git_hash, char * phone,
char * native_sdk_ver, int test1, int test2, int test3, int test4);

int _publish_membench_result(char * url, char * revision, char * runtime, char * git_hash, char * phone,
char * native_sdk_ver, float alloc_str_10, float alloc_str_100, float alloc_void_1, float alloc_void_100,
float alloc_void_1000, float alloc_dummy, float alloc_dummy_struct, float alloc_dummy_mix,
float access_array, float access_vector, float add_vector, float access_dummy, float access_dummy_struct,
float access_dummy_mix);

#ifdef __cplusplus
}
#endif

#endif /* BENCHDB_H_ */
7 changes: 4 additions & 3 deletions tests/Benchmarks/linpack/mosync/linpack.c
Expand Up @@ -28,7 +28,7 @@
#include <conprint.h>
#include <limits.h>
#include <maassert.h>
#include "benchdb.h"
#include <benchdb/benchdb.h>

#define SP

Expand Down Expand Up @@ -175,8 +175,9 @@ static REAL linpack(long nreps,int arsize)
nreps,totalt,100.*tdgefa/totalt,
100.*tdgesl/totalt,100.*toverhead/totalt,
kflops/1000.0);
if(totalt > 10.)
publish_linpack_result("http://127.0.0.1/benchmarks/publish_result.php", "1337", "MoSync", "987123ab", "HTC%20Wildfire", "2", kflops/1000.0);
if(totalt > 10.){ //publish the result in the benchmark database
publish_linpack_result("http://modev.mine.nu:8070/benchmark/publish_result.php", "1337", "MoSync", "987123ab", "HTC%20Wildfire", "2", kflops/1000.0);
}
return(totalt);
}

Expand Down

0 comments on commit bea840b

Please sign in to comment.