Threading test added
This commit is contained in:
@@ -140,7 +140,6 @@ public:
|
||||
for (ssize_t i = 0; i < n; i++) {
|
||||
retval <<= 1;
|
||||
if (q[0] > intensity)
|
||||
//retval |= uint64_t(1);
|
||||
retval++;
|
||||
q = q + local_image->channels();
|
||||
}
|
||||
|
||||
@@ -253,6 +253,30 @@ void DescriptorManager::runExperiments() {
|
||||
}
|
||||
}
|
||||
|
||||
//Test post please ignore
|
||||
void DescriptorManager::test() {
|
||||
const uint64_t n = 1000000000;
|
||||
//string insert = "constant"; //assuming string value doesn't matter.
|
||||
int method = 2;
|
||||
{
|
||||
|
||||
high_resolution_clock::time_point t1 = high_resolution_clock::now();
|
||||
int target_distance = 5;
|
||||
uint64_t better_count = 0;
|
||||
map<string, uint64_t>::iterator it = features[method].begin();
|
||||
for (uint64_t i = 0; i < n; i++) {
|
||||
uint64_t a = (it++->second);
|
||||
uint64_t b = (it++->second);
|
||||
if(descriptor_types[method]->distance(a, b) <= target_distance) better_count++;
|
||||
if(it == features[method].end()) it = features[method].begin();
|
||||
}
|
||||
high_resolution_clock::time_point t2 = high_resolution_clock::now();
|
||||
duration<double> time_span = duration_cast<duration<double>>(t2 - t1);
|
||||
cout << "It took me " << time_span.count() << " seconds to sort " << n << " big numbers." << endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//outputs the gathered data to iostream
|
||||
//Tries to do some nice formatting and grouping of bits.
|
||||
void DescriptorManager::outputMap(int a) {
|
||||
|
||||
+4
-5
@@ -5,20 +5,17 @@
|
||||
#include <bitset>
|
||||
#include <climits>
|
||||
#include <set>
|
||||
#include <thread>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/system/error_code.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
//Boost serialization test:
|
||||
#include <boost/archive/binary_oarchive.hpp>
|
||||
#include <boost/archive/binary_iarchive.hpp>
|
||||
#include <boost/serialization/map.hpp>
|
||||
#include <boost/serialization/bitset.hpp>
|
||||
#include <boost/serialization/string.hpp>
|
||||
|
||||
//YAS Serialization:
|
||||
//#include <yas/serialize.hpp>
|
||||
//#include <yas/std_types.hpp>
|
||||
|
||||
#include <chrono> //Debug, for measuring execution times
|
||||
|
||||
#include <Magick++.h>
|
||||
@@ -51,6 +48,7 @@ public:
|
||||
void rankImages(string image_name, int method);
|
||||
multiset<pair<uint64_t, string>> rankMutations(string image_name, int method);
|
||||
void runExperiments();
|
||||
void test();
|
||||
void generatePreviews(string imagename);
|
||||
void outputMap(int a);
|
||||
void outputMap();
|
||||
@@ -65,6 +63,7 @@ private:
|
||||
Mutation* mutators[numMutations];
|
||||
|
||||
Image* current_image = NULL; //for caching purposes
|
||||
//TODO: Are maps the best container for us? Logarithmic random access is bad, but otherwise it might be fine?
|
||||
map<string, uint64_t> features[numDescriptors]; //array of maps that will hold the descriptors
|
||||
map<string, uint64_t> mutatedFeatures[numDescriptors][numMutations];
|
||||
multiset<pair<uint64_t, string> > distances; //multiset that stores the distances
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
CXX = g++
|
||||
CC = $(CXX)
|
||||
CPPFLAGS = -O2 `Magick++-config --cppflags`
|
||||
CPPFLAGS = -O3 `Magick++-config --cppflags`
|
||||
BOOST_LIBS = -lboost_system -lboost_filesystem -lboost_serialization
|
||||
LDFLAGS = `Magick++-config --ldflags` $(BOOST_LIBS)
|
||||
LDFLAGS = `Magick++-config --ldflags` $(BOOST_LIBS) -lpthread
|
||||
SOURCES = DescriptorManager.cpp main.cpp
|
||||
OBJECTS = $(SOURCES:.cpp=.o)
|
||||
|
||||
|
||||
@@ -27,8 +27,20 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
InitializeMagick(*argv);
|
||||
DescriptorManager* manager = new DescriptorManager("test");
|
||||
manager->Init();
|
||||
manager->Init();/*
|
||||
manager->rankImages(imagename, method);
|
||||
manager->outputRank(imagename, method);
|
||||
manager->outputMap(method);*/
|
||||
cout << endl;
|
||||
|
||||
cout << "Starting first compute thread.." << endl;
|
||||
thread first(&DescriptorManager::test, manager);
|
||||
cout << "Starting second computer thread.." << endl;
|
||||
thread second(&DescriptorManager::test, manager);
|
||||
first.join();
|
||||
|
||||
second.join();
|
||||
cout << "we done." << endl;
|
||||
//manager->test();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user