当前位置: 首页>>代码示例>>C++>>正文


C++ Store::WriteEnvelope方法代码示例

本文整理汇总了C++中Store::WriteEnvelope方法的典型用法代码示例。如果您正苦于以下问题:C++ Store::WriteEnvelope方法的具体用法?C++ Store::WriteEnvelope怎么用?C++ Store::WriteEnvelope使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Store的用法示例。


在下文中一共展示了Store::WriteEnvelope方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fos

TEST_F(Benchmark, SimpleStoreIO)
{
    {
        const int32 n = 1000000;
        Envelope e;

        Store * s = this->GetTemporaryStore();
        ASSERT_TRUE(s->CreateBucket("foo"));
        ASSERT_TRUE(s->CreateStreamset("foo", "bar"));

        TIMER_START(n);
        s->WriteEnvelope("foo", "bar", e);
        TIMER_END("zippylog.store.write_1M_empty_envelopes");
    }

    {
        const int32 n = 1000000;
        Envelope e;

        string path = ::zippylog::platform::PathJoin(this->GetTemporaryDirectory(), "s.zippylog");

        {
            ::zippylog::FileOutputStream fos(path);
            for (int32 i = 0; i < n; i++) {
                fos.WriteEnvelope(e);
            }
        }

        ::zippylog::FileInputStream fis(path);
        uint32 read;
        TIMER_START(n);
        fis.ReadEnvelope(e, read);
        TIMER_END("zippylog.FileInputStream.read_1M_empty_envelopes");
    }

    {
        const int32 n = 1000000;

        Envelope *envelopes = new Envelope[n];
        for (int32 i = 0; i < n; i++) {
            envelopes[i] = this->GetRandomEnvelope();
        }

        {
            Store * s = this->GetTemporaryStore();
            ASSERT_TRUE(s->CreateBucket("foo"));
            ASSERT_TRUE(s->CreateStreamset("foo", "bar"));

            TIMER_START_SINGLE();
            for (int32 i = 0; i < n; i++) {
                s->WriteEnvelope("foo", "bar", envelopes[i]);
            }
            TIMER_END_COUNT("zippylog.store.write_1M_random_envelopes", n);
        }

        {
            string path = ::zippylog::platform::PathJoin(this->GetTemporaryDirectory(), "s.zippylog");

            {
                ::zippylog::FileOutputStream fos(path);
                TIMER_START(n);
                fos.WriteEnvelope(envelopes[TIMER_LOOP_VALUE - 1]);
                TIMER_END("zippylog.FileOutputStream.write_1M_random_envelopes");
            }

            Envelope e;
            ::zippylog::FileInputStream fis(path);
            uint32 read;
            TIMER_START(n);
            fis.ReadEnvelope(e, read);
            TIMER_END("zippylog.FileInputStream.read_1M_random_envelopes");
        }

        delete [] envelopes;
    }
}
开发者ID:trink,项目名称:zippylog,代码行数:76,代码来源:zippylogbench.cpp


注:本文中的Store::WriteEnvelope方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。