<commit_before>/*
 * IODescriptors_test.cpp
 *
 *  Created on: Nov 21, 2013
 *      Author: andresf
 */

#include <gtest/gtest.h>
#include <opencv2/core/core.hpp>

#include <FileUtils.hpp>

TEST(IODescriptors, LoadSave) {

	cv::Mat original;
	FileUtils::loadDescriptors("all_souls_000000.yaml.gz", original);

	FileUtils::saveDescriptors("sift_desc_tmp.yaml.gz", original);
	cv::Mat loaded;
	FileUtils::loadDescriptors("sift_desc_tmp.yaml.gz", loaded);

	// Check number of rows, columns and type are equal
	EXPECT_TRUE(original.rows == loaded.rows);
	EXPECT_TRUE(original.cols == loaded.cols);
	EXPECT_TRUE(original.type() == loaded.type());

	// Check elements are equal
	for (int i = 0; i < original.rows; i++) {
		for (int j = 0; j < original.cols; j++) {
			EXPECT_TRUE(original.at<float>(i, j) == loaded.at<float>(i, j));
		}
	}

}
<commit_msg>Common/tests/IODescriptors_test.cpp * Implemented tests for testing methods FileUilts::saveDescriptors and FileUilts::loadDescriptors.<commit_after>/*
 * IODescriptors_test.cpp
 *
 *  Created on: Nov 21, 2013
 *      Author: andresf
 */

#include <gtest/gtest.h>
#include <opencv2/core/core.hpp>
#include <opencv2/flann/logger.h>

#include <FileUtils.hpp>

TEST(IODescriptors, LoadSave) {

	cv::Mat original;
	FileUtils::loadDescriptors("all_souls_000000.yaml.gz", original);
	FileUtils::saveDescriptors("sift_desc_tmp.yaml.gz", original);

	cv::Mat loaded;
	FileUtils::loadDescriptors("sift_desc_tmp.yaml.gz", loaded);

	// Check number of rows, columns and type are equal
	EXPECT_TRUE(original.rows == loaded.rows);
	EXPECT_TRUE(original.cols == loaded.cols);
	EXPECT_TRUE(original.type() == loaded.type());

	// Check elements are equal
	for (int i = 0; i < original.rows; i++) {
		for (int j = 0; j < original.cols; j++) {
			EXPECT_TRUE(original.at<float>(i, j) == loaded.at<float>(i, j));
		}
	}

}

TEST(IODescriptors, LoadStress) {

	cvflann::Logger::setDestination("load_times.log");

	cv::Mat descriptors;

	for (size_t i = 0; i < 5008; i++) {
		descriptors = cv::Mat();

		double mytime = cv::getTickCount();
		FileUtils::loadDescriptors("all_souls_000000.yaml.gz", descriptors);
		mytime = (double(cv::getTickCount()) - mytime) / cv::getTickFrequency()
				* 1000.0;

		cvflann::Logger::log(0, "%lf\n", mytime);
	}
}
{'fraction_non_alphanumeric': 0.16505706760316066, 'fraction_numerical': 0.021071115013169446, 'mean_word_length': 4.813775510204081, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5089653', 'n_tokens_mistral': 893, 'n_tokens_neox': 852, 'n_words': 165}