Skip to content

Commit

Permalink
netbeans conf auto change, additional files
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Kraynyukhov committed Jul 2, 2018
1 parent ccfe12e commit 3e412af
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 41 deletions.
66 changes: 26 additions & 40 deletions benchmark/echo_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,19 @@

typedef websocketpp::client<websocketpp::config::asio_client> client;



using websocketpp::lib::placeholders::_1;
using websocketpp::lib::placeholders::_2;
using websocketpp::lib::bind;

std::string blob(1024,'c');
size_t rounds_per_run=10000;

size_t om_counter=0;

uint64_t start=0;
uint64_t slice=0;

std::string outblob(1024,'x');

const uint64_t time_now()
{
return std::chrono::duration_cast<std::chrono::milliseconds>(
Expand All @@ -59,74 +60,59 @@ typedef websocketpp::config::asio_client::message_type::ptr message_ptr;
// prints the message and then sends a copy of the message back to the server.
void on_message(client* c, websocketpp::connection_hdl hdl, message_ptr msg)
{

//std::cout << "Message received: " << msg->get_payload() << std::endl;
//
om_counter++;

if(om_counter == rounds_per_run)
slice=time_now();
if((slice - start) >= 1000)
{
slice=time_now();
size_t ms = slice - start;
std::cout << om_counter << " messages of size " << blob.size() << " octets have had their roundtrips within " << ms << " ms " << std::endl;
std::cout << "average rountrip time: " << float(om_counter)/float(ms) << " per ms, or " << (float(om_counter)/float(ms))*1000.0f << " roundtrips per second" << std::endl;
std::cout << "tabdata: " << blob.size() << " " << (float(om_counter)/float(ms))*1000.0f << std::endl;
// 512kb max, no reason for larger blobs so far.
if(blob.size() < 262144/4)
{
blob=std::move(std::string(blob.size()*2,'x'));
}
else{
std::cout << "finished" << std::endl;
exit(0);
}
om_counter=0;
std::cout << "Messages " << om_counter << " per " << slice - start << "ms" << std::endl;
start=time_now();
om_counter=0;
}


websocketpp::lib::error_code ec;

c->send(hdl, blob, websocketpp::frame::opcode::binary, ec);
c->send(hdl, outblob, websocketpp::frame::opcode::binary, ec);
if (ec) {
std::cout << "Echo failed because: " << ec.message() << std::endl;
}
//std::cout << "Message have been sent" << std::endl;
}

void on_open(client* c, websocketpp::connection_hdl hdl)
{
websocketpp::lib::error_code ec;
c->send(hdl,blob,websocketpp::frame::opcode::text,ec);
c->send(hdl,outblob,websocketpp::frame::opcode::binary,ec);
c->send(hdl,outblob,websocketpp::frame::opcode::binary,ec);
if(ec)
{
std::cout << "Can't send a message: " << ec.message() << std::endl;
}
// else c->get_alog().write(websocketpp::log::alevel::app, "Sent Message: test");

// speedup
c->send(hdl,"", websocketpp::frame::opcode::binary,ec);
if(ec)
{
std::cout << "Can't send a message: " << ec.message() << std::endl;
}

start=time_now();
// get sock_fd:
// auto skt=c->get_con_from_hdl(hdl)->get_raw_socket().native_handle();

}


int main(int argc, char* argv[]) {
// Create a client endpoint
client c;

//websocketpp::transport::asio::tls_socket::tls_init_handler f=on_tls_init;
//c.set_tls_init_handler(f);


std::string uri = "ws://localhost:5083/echo";
std::string uri;

if (argc == 2) {
uri = argv[1];
if (argc < 2)
{
std::cout << "Usage: " << argv[0] << " uri [bytes per message]" << std::endl;
} else {
uri = argv[1];
if(argc==3)
{
outblob=std::string(std::strtoll(argv[2],NULL,10),'x');
}
}


try {
// Set logging to be pretty verbose (everything except message payloads)
Expand Down
2 changes: 1 addition & 1 deletion benchmark/nbench.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fi

echo Running $CLIENTS echo-processes with $BSIZE bytes large messages

rm -f log.*; let j=0;while [ $j -lt $CLIENTS ]; do ./benchmark wss://localhost:5083/echo $BSIZE >log.$j & let j++; done > /dev/null 2>&1
rm -f log.*; let j=0;while [ $j -lt $CLIENTS ]; do ./benchmark ws://localhost:5083/echo $BSIZE >log.$j & let j++; done


sleep 10
Expand Down
4 changes: 4 additions & 0 deletions nbproject/Package-Debug.bash
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,10 @@ cd "${TOP}"
makeDirectory "${NBTMPDIR}//usr/bin"
copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755

cd "${TOP}"
makeDirectory "${NBTMPDIR}//usr/bin"
copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755


# Create control file
cd "${TOP}"
Expand Down
12 changes: 12 additions & 0 deletions nbproject/configurations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,18 @@
perm="755"
owner="root"
group="bin"/>
<packFileListElem type="File"
to="${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}"
from="${OUTPUT_PATH}"
perm="755"
owner="root"
group="bin"/>
<packFileListElem type="File"
to="${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}"
from="${OUTPUT_PATH}"
perm="755"
owner="root"
group="bin"/>
</packFileList>
<packInfoList>
<packInfoListElem name="Package" value="lapps" mandatory="true"/>
Expand Down

0 comments on commit 3e412af

Please # to comment.