gv = new char*[3];
?tmp_argv[0] = "";
?tmp_argv[1] = "--big_menu=false";
?tmp_argv[2] = "--languages=chinese";
?//google::ParseCommandLineFlags(&argc, &argv, true);
?google::ParseCommandLineFlags(&tmp_argc, &tmp_argv, true);
?std::cout << "argc=" << argc << std::endl;
?if (FLAGS_big_menu) {
? std::cout << "big menu is ture" << std::endl;
?}
?else {
? std::cout << "big menu is flase" << std::endl;
?}
?std::cout << "languages=" << FLAGS_languages << std::endl;
?return 0;
}
void thread1_test()
{
?std::string strTmp = "thread1_test";
?for (int i = 0; i< 1000; i++) {
? //LOG(INFO) << i;
? LOG_IF(INFO, i < 10) << i;
? //CHECK_EQ(i, 100) << "error!";
? //LOG(INFO) << strTmp;
? //Sleep(10);
?}
}
void thread2_test()
{
?std::string strTmp = "thread2_test";
?for (int i = 1000; i< 2000; i++) {
? //LOG(INFO) << i;
? LOG_IF(INFO, i < 1100) << i;
? //LOG(INFO) << strTmp;
? //Sleep(10);
?}
}
int test_GLog()
{
?//http://www.yeolar.com/note/2014/12/20/glog/
?//http://www.cppblog.com/pizzx/archive/2014/06/18/207320.aspx
?const char* exe = "E:/GitCode/Caffe/lib/dbg/x86_vc12/testThridLibrary[dbg_x86_vc12].exe";
?//Initialize Google's logging library.
?//google::InitGoogleLogging(argv[0]);
?google::InitGoogleLogging(exe);
?//为不同级别的日志设置不同的文件basename。
?google::SetLogDestination(google::INFO, "E:/tmp/loginfo");
?google::SetLogDestination(google::WARNING, "E:/tmp/logwarn");
?google::SetLogDestination(google::GLOG_ERROR, "E:/tmp/logerror");
?
?//缓存的最大时长,超时会写入文件
?FLAGS_logbufsecs = 60;
?//单个日志文件最大,单位M
?FLAGS_max_log_size = 10;
?//设置为true,就不会写日志文件了
?FLAGS_logtostderr = false;
?boost::thread t1(boost::bind(&thread1_test));
?boost::thread t2(boost::bind(&thread2_test));
?t1.join();
?t2.join();
?//LOG(FATAL)<<"exit";
?google::ShutdownGoogleLogging();
?return 0;
}
int test_LevelDB()
{
?//http://www.cnblogs.com/haippy/archive/2011/12/04/2276064.html
?//http://www.bubuko.com/infodetail-411090.html
?//http://qiuqiang1985.iteye.com/blog/1255365
?leveldb::DB* db;
?leveldb::Options options;
?options.create_if_missing = true;
?leveldb::Status status = leveldb::DB::Open(options, "E:/tmp/testLevelDB", &db);
?assert(status.ok());
?//write key1,value1
?std::string key = "key";
?std::string value = "value";
?//write
?status = db->Put(leveldb::WriteOptions(), key, value);
?assert(status.ok());
?//read
?status = db->Get(leveldb::ReadOptions(), key, &value);
?assert(status.ok());
?std::cout << value << std::endl;
?std::string key2 = "key2";
?//move the value under key to key2
?status = db->Put(leveldb::WriteOptions(), key2, value);
?assert(status.ok());
?//delete
?status = db->Delete(leveldb::WriteOptions(), key);
?assert(status.ok());
?status = db->Get(leveldb::ReadOptions(), key2, &value);
?assert(status.ok());
?std::cout << key2 << "===" << value << std::endl;
?
?status = db->Get(leveldb::ReadOptions(), key, &value);
?if (!status.ok())
? std::cerr << key << "? " << status.ToString() << std::endl;
?else
? std::cout << key << "===" << value << std::endl;
?delete db;
?return 0;
}
#define E(expr) CHECK((rc = (expr)) == MDB_SUCCESS, #expr)
#define RES(err, expr) ((rc = expr) == (err) || (CHECK(!rc, #expr), 0))
#define CHECK(test, msg) ((test) ? (void)0 : ((void)fprintf(stderr, \
?"%s:%d: %s: %s\n", __FILE__, __LINE__, msg, mdb_strerror(rc)), abort()))
int test_LMDB()
{
?//http://www.jianshu.com/p/yzFf8j
?//./lmdb-mdb.master/libraries/liblmdb/mtest.c
?int i = 0, j = 0, rc;
?MDB_env *env;
?MDB_dbi dbi;
?MDB_val key, data;
?MDB_txn *txn;
?MDB_stat mst;
?MDB_cursor *cursor, *cur2;
?MDB_cursor_op op;
?int count;
?int *values;
?char sval[32] = "";
?srand(time(NULL));
?count = (rand() % 384) + 64;
?values = (int *)malloc(count*sizeof(int));
?for (i = 0; i? values[i] = rand() % 1024;
?}
?E(mdb_env_create(&env));
?E(mdb_env_set_ma