Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- #include "md5.h"
- #include <thread>
- using namespace std;
- MD5 md5;
- const string CHARACTERS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
- char randstring[32];
- string RandomString() {
- srand((unsigned int)time(NULL));
- for (int i = 0; i<32; i++) {
- randstring[i] = CHARACTERS[rand() % 62];
- }
- return randstring;
- }
- void LoopMD5() {
- for (int i = 0; i<500000; i++) {
- md5(RandomString());
- }
- }
- int main() {
- time_t time_start = time(0);
- thread t1(LoopMD5);
- thread t2(LoopMD5);
- t1.join();
- t2.join();
- time_t time_end = time(0);
- time_t execution_time = (time_end - time_start);
- cout << "Content-type:text/html\r\n\r\n";
- cout << "<!DOCTYPE html>\n";
- cout << "<html>\n";
- cout << "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n";
- cout << "<meta charset=\"UTF-8\">\n";
- cout << "<title>Test C++ Threaded Page</title>\n";
- cout << "<link href=\"http://fonts.googleapis.com/css?family=Open+Sans:400,400italic,700,700italic&subset=latin,latin-ext,cyrillic-ext\" rel=\"stylesheet\" type=\"text/css\">\n";
- cout << "<link rel=\"stylesheet\" href=\"/css/style.css\">\n";
- cout << "</head>\n";
- cout << "<body>\n";
- cout << "<div class=\"page-wrapper\">\n";
- cout << "<div id=\"page-content\">This shit had " << execution_time << " seconds to execute</div>\n";
- cout << "</div>\n";
- cout << "</body>\n";
- cout << "</html>\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement