亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? lzmabench.cpp

?? lzma 壓縮 4.06version
?? CPP
字號:
// LzmaBench.cpp

#include "StdAfx.h"

#include "LzmaBench.h"

#ifndef WIN32
#include <time.h>
#endif

#include "../../../Common/CRC.h"
#include "../LZMA/LZMADecoder.h"
#include "../LZMA/LZMAEncoder.h"

static const UInt32 kAdditionalSize = 
#ifdef _WIN32_WCE
(1 << 20);
#else
(6 << 20);
#endif

static const UInt32 kCompressedAdditionalSize = (1 << 10);
static const UInt32 kMaxLzmaPropSize = 10;

class CRandomGenerator
{
  UInt32 A1;
  UInt32 A2;
public:
  CRandomGenerator() { Init(); }
  void Init() { A1 = 362436069; A2 = 521288629;}
  UInt32 GetRnd() 
  {
    return 
      ((A1 = 36969 * (A1 & 0xffff) + (A1 >> 16)) << 16) ^
      ((A2 = 18000 * (A2 & 0xffff) + (A2 >> 16)) );
  }
};

class CBitRandomGenerator
{
  CRandomGenerator RG;
  UInt32 Value;
  int NumBits;
public:
  void Init()
  {
    Value = 0;
    NumBits = 0;
  }
  UInt32 GetRnd(int numBits) 
  {
    if (NumBits > numBits)
    {
      UInt32 result = Value & ((1 << numBits) - 1);
      Value >>= numBits;
      NumBits -= numBits;
      return result;
    }
    numBits -= NumBits;
    UInt32 result = (Value << numBits);
    Value = RG.GetRnd();
    result |= Value & ((1 << numBits) - 1);
    Value >>= numBits;
    NumBits = 32 - numBits;
    return result;
  }
};

class CBenchRandomGenerator
{
  CBitRandomGenerator RG;
  UInt32 Pos;
public:
  UInt32 BufferSize;
  Byte *Buffer;
  CBenchRandomGenerator(): Buffer(0) {} 
  ~CBenchRandomGenerator() { delete []Buffer; }
  void Init() { RG.Init(); }
  void Set(UInt32 bufferSize) 
  {
    delete []Buffer;
    Buffer = 0;
    Buffer = new Byte[bufferSize];
    Pos = 0;
    BufferSize = bufferSize;
  }
  UInt32 GetRndBit() { return RG.GetRnd(1); }
  /*
  UInt32 GetLogRand(int maxLen)
  {
    UInt32 len = GetRnd() % (maxLen + 1);
    return GetRnd() & ((1 << len) - 1);
  }
  */
  UInt32 GetLogRandBits(int numBits)
  {
    UInt32 len = RG.GetRnd(numBits);
    return RG.GetRnd(len);
  }
  UInt32 GetOffset()
  {
    if (GetRndBit() == 0)
      return GetLogRandBits(4);
    return (GetLogRandBits(4) << 10) | RG.GetRnd(10);
  }
  UInt32 GetLen()
  {
    if (GetRndBit() == 0)
      return RG.GetRnd(2);
    if (GetRndBit() == 0)
      return 4 + RG.GetRnd(3);
    return 12 + RG.GetRnd(4);
  }
  void Generate()
  {
    while(Pos < BufferSize)
    {
      if (GetRndBit() == 0 || Pos < 1)
        Buffer[Pos++] = Byte(RG.GetRnd(8));
      else
      {
        UInt32 offset = GetOffset();
        while (offset >= Pos)
          offset >>= 1;
        offset += 1;
        UInt32 len = 2 + GetLen();
        for (UInt32 i = 0; i < len && Pos < BufferSize; i++, Pos++)
          Buffer[Pos] = Buffer[Pos - offset];
      }
    }
  }
};

class CBenchmarkInStream: 
  public ISequentialInStream,
  public CMyUnknownImp
{
  const Byte *Data;
  UInt32 Pos;
  UInt32 Size;
public:
  MY_UNKNOWN_IMP
  void Init(const Byte *data, UInt32 size)
  {
    Data = data;
    Size = size;
    Pos = 0;
  }
  STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
  STDMETHOD(ReadPart)(void *data, UInt32 size, UInt32 *processedSize);
};

STDMETHODIMP CBenchmarkInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
{
  UInt32 remain = Size - Pos;
  if (size > remain)
    size = remain;
  for (UInt32 i = 0; i < size; i++)
  {
    ((Byte *)data)[i] = Data[Pos + i];
  }
  Pos += size;
  if(processedSize != NULL)
    *processedSize = size;
  return S_OK;
}
  
STDMETHODIMP CBenchmarkInStream::ReadPart(void *data, UInt32 size, UInt32 *processedSize)
{
  return Read(data, size, processedSize);
}

class CBenchmarkOutStream: 
  public ISequentialOutStream,
  public CMyUnknownImp
{
  UInt32 BufferSize;
  FILE *_f;
public:
  UInt32 Pos;
  Byte *Buffer;
  CBenchmarkOutStream(): _f(0), Buffer(0) {} 
  virtual ~CBenchmarkOutStream() { delete []Buffer; }
  void Init(FILE *f, UInt32 bufferSize) 
  {
    delete []Buffer;
    Buffer = 0;
    Buffer = new Byte[bufferSize];
    Pos = 0;
    BufferSize = bufferSize;
    _f = f;
  }
  MY_UNKNOWN_IMP
  STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
  STDMETHOD(WritePart)(const void *data, UInt32 size, UInt32 *processedSize);
};

STDMETHODIMP CBenchmarkOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
{
  UInt32 i;
  for (i = 0; i < size && Pos < BufferSize; i++)
    Buffer[Pos++] = ((const Byte *)data)[i];
  if(processedSize != NULL)
    *processedSize = i;
  if (i != size)
  {
    fprintf(_f, "\nERROR: Buffer is full\n");
    return E_FAIL;
  }
  return S_OK;
}
  
STDMETHODIMP CBenchmarkOutStream::WritePart(const void *data, UInt32 size, UInt32 *processedSize)
{
  return Write(data, size, processedSize);
}

class CCrcOutStream: 
  public ISequentialOutStream,
  public CMyUnknownImp
{
public:
  CCRC CRC;
  MY_UNKNOWN_IMP
  void Init() { CRC.Init(); }
  STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
  STDMETHOD(WritePart)(const void *data, UInt32 size, UInt32 *processedSize);
};

STDMETHODIMP CCrcOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
{
  CRC.Update(data, size);
  if(processedSize != NULL)
    *processedSize = size;
  return S_OK;
}
  
STDMETHODIMP CCrcOutStream::WritePart(const void *data, UInt32 size, UInt32 *processedSize)
{
  return Write(data, size, processedSize);
}

static UInt64 GetTimeCount()
{
  #ifdef WIN32
  LARGE_INTEGER value;
  if (::QueryPerformanceCounter(&value))
    return value.QuadPart;
  return GetTickCount();
  #else
  return clock();
  #endif 
}

static UInt64 GetFreq()
{
  #ifdef WIN32
  LARGE_INTEGER value;
  if (::QueryPerformanceFrequency(&value))
    return value.QuadPart;
  return 1000;
  #else
  return CLOCKS_PER_SEC;
  #endif 
}

struct CProgressInfo:
  public ICompressProgressInfo,
  public CMyUnknownImp
{
  UInt64 ApprovedStart;
  UInt64 InSize;
  UInt64 Time;
  void Init()
  {
    InSize = 0;
    Time = 0;
  }
  MY_UNKNOWN_IMP
  STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
};

STDMETHODIMP CProgressInfo::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
{
  if (*inSize >= ApprovedStart && InSize == 0)
  {
    Time = ::GetTimeCount();
    InSize = *inSize;
  }
  return S_OK;
}

static const int kSubBits = 8;

static UInt32 GetLogSize(UInt32 size)
{
  for (int i = kSubBits; i < 32; i++)
    for (UInt32 j = 0; j < (1 << kSubBits); j++)
      if (size <= (((UInt32)1) << i) + (j << (i - kSubBits)))
        return (i << kSubBits) + j;
  return (32 << kSubBits);
}

static UInt64 MyMultDiv64(UInt64 value, UInt64 elapsedTime)
{
  UInt64 freq = GetFreq();
  UInt64 elTime = elapsedTime;
  while(freq > 1000000)
  {
    freq >>= 1;
    elTime >>= 1;
  }
  if (elTime == 0)
    elTime = 1;
  return value * freq / elTime;
}

static UInt64 GetCompressRating(UInt32 dictionarySize, bool isBT4,
    UInt64 elapsedTime, UInt64 size)
{
  UInt64 numCommandsForOne;
  if (isBT4)
  {
    UInt64 t = GetLogSize(dictionarySize) - (19 << kSubBits);
    numCommandsForOne = 2000 + ((t * t * 68) >> (2 * kSubBits));
  }
  else
  {
    UInt64 t = GetLogSize(dictionarySize) - (15 << kSubBits);
    numCommandsForOne = 1500 + ((t * t * 41) >> (2 * kSubBits));
  }
  UInt64 numCommands = (UInt64)(size) * numCommandsForOne;
  return MyMultDiv64(numCommands, elapsedTime);
}

static UInt64 GetDecompressRating(UInt64 elapsedTime, 
    UInt64 outSize, UInt64 inSize)
{
  UInt64 numCommands = inSize * 250 + outSize * 21;
  return MyMultDiv64(numCommands, elapsedTime);
}

static UInt64 GetTotalRating(
    UInt32 dictionarySize, 
    bool isBT4,
    UInt64 elapsedTimeEn, UInt64 sizeEn,
    UInt64 elapsedTimeDe, 
    UInt64 inSizeDe, UInt64 outSizeDe)
{
  return (GetCompressRating(dictionarySize, isBT4, elapsedTimeEn, sizeEn) + 
    GetDecompressRating(elapsedTimeDe, inSizeDe, outSizeDe)) / 2;
}

static void PrintRating(FILE *f, UInt64 rating)
{
  fprintf(f, "%5d MIPS", (unsigned int)(rating / 1000000));
}

static void PrintResults(
    FILE *f, 
    UInt32 dictionarySize,
    bool isBT4,
    UInt64 elapsedTime, 
    UInt64 size, 
    bool decompressMode, UInt64 secondSize)
{
  UInt64 speed = MyMultDiv64(size, elapsedTime);
  fprintf(f, "%6d KB/s  ", (unsigned int)(speed / 1024));
  UInt64 rating;
  if (decompressMode)
    rating = GetDecompressRating(elapsedTime, size, secondSize);
  else
    rating = GetCompressRating(dictionarySize, isBT4, elapsedTime, size);
  PrintRating(f, rating);
}

static void ThrowError(FILE *f, HRESULT result, const char *s)
{
  fprintf(f, "\nError: ");
  if (result == E_ABORT)
    fprintf(f, "User break");
  if (result == E_OUTOFMEMORY)
    fprintf(f, "Can not allocate memory");
  else
    fprintf(f, s);
  fprintf(f, "\n");
}

const wchar_t *bt2 = L"BT2";
const wchar_t *bt4 = L"BT4";

int LzmaBenchmark(FILE *f, UInt32 numIterations, UInt32 dictionarySize, bool isBT4)
{
  if (numIterations == 0)
    return 0;
  if (dictionarySize < (1 << 19) && isBT4 || dictionarySize < (1 << 15))
  {
    fprintf(f, "\nError: dictionary size for benchmark must be >= 19 (512 KB)\n");
    return 1;
  }
  fprintf(f, "\n       Compressing                Decompressing\n\n");
  NCompress::NLZMA::CEncoder *encoderSpec = new NCompress::NLZMA::CEncoder;
  CMyComPtr<ICompressCoder> encoder = encoderSpec;

  NCompress::NLZMA::CDecoder *decoderSpec = new NCompress::NLZMA::CDecoder;
  CMyComPtr<ICompressCoder> decoder = decoderSpec;

  CBenchmarkOutStream *propStreamSpec = new CBenchmarkOutStream;
  CMyComPtr<ISequentialOutStream> propStream = propStreamSpec;
  propStreamSpec->Init(f, kMaxLzmaPropSize);
  
  CBenchmarkInStream *propDecoderStreamSpec = new CBenchmarkInStream;
  CMyComPtr<ISequentialInStream> propDecoderStream = propDecoderStreamSpec;

  PROPID propIDs[] = 
  { 
    NCoderPropID::kDictionarySize,  
    NCoderPropID::kMatchFinder  
  };
  const int kNumProps = sizeof(propIDs) / sizeof(propIDs[0]);
  PROPVARIANT properties[kNumProps];
  properties[0].vt = VT_UI4;
  properties[0].ulVal = UInt32(dictionarySize);

  properties[1].vt = VT_BSTR;
  properties[1].bstrVal = isBT4 ? (BSTR)bt4: (BSTR)bt2;

  const UInt32 kBufferSize = dictionarySize + kAdditionalSize;
  const UInt32 kCompressedBufferSize = (kBufferSize / 2) + kCompressedAdditionalSize;

  if (encoderSpec->SetCoderProperties(propIDs, properties, kNumProps) != S_OK)
  {
    fprintf(f, "\nError: Incorrect command\n");
    return 1;
  }
  encoderSpec->WriteCoderProperties(propStream);

  CBenchRandomGenerator rg;
  rg.Init();
  rg.Set(kBufferSize);
  rg.Generate();
  CCRC crc;
  crc.Update(rg.Buffer, rg.BufferSize);

  CProgressInfo *progressInfoSpec = new CProgressInfo;
  CMyComPtr<ICompressProgressInfo> progressInfo = progressInfoSpec;

  progressInfoSpec->ApprovedStart = dictionarySize;

  UInt64 totalBenchSize = 0;
  UInt64 totalEncodeTime = 0;
  UInt64 totalDecodeTime = 0;
  UInt64 totalCompressedSize = 0;

  for (UInt32 i = 0; i < numIterations; i++)
  {
    progressInfoSpec->Init();
    CBenchmarkInStream *inStreamSpec = new CBenchmarkInStream;
    inStreamSpec->Init(rg.Buffer, rg.BufferSize);
    CMyComPtr<ISequentialInStream> inStream = inStreamSpec;
    CBenchmarkOutStream *outStreamSpec = new CBenchmarkOutStream;
    outStreamSpec->Init(f, kCompressedBufferSize);
    CMyComPtr<ISequentialOutStream> outStream = outStreamSpec;
    HRESULT result = encoder->Code(inStream, outStream, 0, 0, progressInfo);
    UInt64 encodeTime = ::GetTimeCount() - progressInfoSpec->Time;
    UInt32 compressedSize = outStreamSpec->Pos;
    if(result != S_OK)
    {
      ThrowError(f, result, "Encoder Error");
      return 1;
    }
    if (progressInfoSpec->InSize == 0)
    {
      fprintf(f, "\nError: Internal ERROR 1282\n");
      return 1;
    }
  
    ///////////////////////
    // Decompressing
  
    CCrcOutStream *crcOutStreamSpec = new CCrcOutStream;
    CMyComPtr<ISequentialOutStream> crcOutStream = crcOutStreamSpec;
    
    UInt64 decodeTime;
    for (int i = 0; i < 2; i++)
    {
      inStreamSpec->Init(outStreamSpec->Buffer, compressedSize);
      crcOutStreamSpec->Init();
      
      propDecoderStreamSpec->Init(propStreamSpec->Buffer, propStreamSpec->Pos);
      if (decoderSpec->SetDecoderProperties(propDecoderStream) != S_OK)
      {
        fprintf(f, "\nError: Set Decoder Properties Error\n");
        return 1;
      }
      UInt64 outSize = kBufferSize;
      UInt64 startTime = ::GetTimeCount();
      result = decoder->Code(inStream, crcOutStream, 0, &outSize, 0);
      decodeTime = ::GetTimeCount() - startTime;
      if(result != S_OK)
      {
        ThrowError(f, result, "Decode Error");
        return 1;
      }
      if (crcOutStreamSpec->CRC.GetDigest() != crc.GetDigest())
      {
        fprintf(f, "\nError: CRC Error\n");
        return 1;
      }
    }
    UInt64 benchSize = kBufferSize - progressInfoSpec->InSize;
    PrintResults(f, dictionarySize, isBT4, encodeTime, benchSize, false, 0);
    fprintf(f, "     ");
    PrintResults(f, dictionarySize, isBT4, decodeTime, kBufferSize, true, compressedSize);
    fprintf(f, "\n");

    totalBenchSize += benchSize;
    totalEncodeTime += encodeTime;
    totalDecodeTime += decodeTime;
    totalCompressedSize += compressedSize;
  }
  fprintf(f, "---------------------------------------------------\n");
  PrintResults(f, dictionarySize, isBT4, totalEncodeTime, totalBenchSize, false, 0);
  fprintf(f, "     ");
  PrintResults(f, dictionarySize, isBT4, totalDecodeTime, 
      kBufferSize * numIterations, true, totalCompressedSize);
  fprintf(f, "    Average\n");
  return 0;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久噜噜噜久噜久久综合| 亚洲国产一区二区三区 | 久久99精品久久久久久久久久久久| 亚洲精品免费在线观看| 亚洲妇女屁股眼交7| 亚洲精品视频观看| 国产在线播放一区| 欧美精品精品一区| 亚洲国产精品av| 亚州成人在线电影| 99久久er热在这里只有精品15| 亚洲精品一区二区三区精华液 | 在线观看av一区| 精品99一区二区| 亚洲18色成人| 成人免费看片app下载| 欧美精品丝袜久久久中文字幕| 国产精品第13页| 国产69精品久久99不卡| 欧美巨大另类极品videosbest | 日韩高清在线不卡| 久久久激情视频| 国产乱码一区二区三区| 国产精品久久久久影视| 欧美精品日韩综合在线| 国产丝袜欧美中文另类| 日韩电影免费在线| 欧美精品乱码久久久久久按摩 | 日本少妇一区二区| 国产女同互慰高潮91漫画| 欧美日韩国产一级片| 成人一区在线观看| 韩国女主播一区| 国产一区二区三区日韩| 色综合色狠狠综合色| 亚洲国产精品久久人人爱 | 国产一区二区三区av电影| 2欧美一区二区三区在线观看视频| 国产精品麻豆99久久久久久| 色婷婷综合久久久久中文| 夜夜揉揉日日人人青青一国产精品| 日韩一区二区影院| 日韩你懂的在线观看| 粉嫩绯色av一区二区在线观看| 337p日本欧洲亚洲大胆精品 | 不卡区在线中文字幕| 亚洲精品在线电影| 国产一区二区调教| 久久精品人人做人人爽人人| 欧美三级中文字幕在线观看| 国产在线一区二区综合免费视频| 成人欧美一区二区三区| 欧美激情在线一区二区三区| 亚洲超碰97人人做人人爱| 国产精品久久久久久久久免费相片 | 99精品视频免费在线观看| 国产精品99久久久久久宅男| 粉嫩一区二区三区在线看| 不卡av电影在线播放| 丁香婷婷综合色啪| 91论坛在线播放| 欧美一区二区三区在线电影| 日韩女优av电影| 中文字幕av不卡| 亚洲日本乱码在线观看| 午夜欧美视频在线观看| 日韩一区精品字幕| 另类小说色综合网站| 丰满亚洲少妇av| 欧美在线免费视屏| 日韩欧美国产电影| 久久久综合视频| 激情欧美日韩一区二区| 国产成人免费网站| 日本高清无吗v一区| 欧美福利一区二区| 欧美国产日韩精品免费观看| 亚洲美女在线一区| 精品在线亚洲视频| 91日韩在线专区| 欧美精品三级日韩久久| 久久久精品影视| 亚洲精品免费看| 久久国产精品免费| 色综合久久综合中文综合网| 欧美日韩精品一区二区天天拍小说| 337p亚洲精品色噜噜噜| 亚洲国产精品传媒在线观看| 亚洲妇熟xx妇色黄| 国产毛片精品一区| 欧美性大战久久久久久久蜜臀| 精品国产乱码久久久久久闺蜜| 中文字幕在线不卡一区| 视频在线在亚洲| 成人午夜大片免费观看| 91精品国产91热久久久做人人| 中文字幕成人av| 蜜臀av性久久久久蜜臀aⅴ流畅| 99在线精品视频| 精品女同一区二区| 亚洲午夜精品久久久久久久久| 成人小视频免费在线观看| 日韩一级黄色片| 夜夜亚洲天天久久| 成人午夜看片网址| 精品国产91洋老外米糕| 亚洲无人区一区| 91麻豆福利精品推荐| 欧美高清在线精品一区| 精品影视av免费| 欧美日韩精品一区视频| 亚洲男人的天堂在线aⅴ视频| 国产精品1区2区3区| 日韩精品一区国产麻豆| 日产国产欧美视频一区精品| 欧美特级限制片免费在线观看| 中文字幕国产一区| 国产精品自拍在线| 日韩美一区二区三区| 性欧美大战久久久久久久久| 一本色道亚洲精品aⅴ| 综合激情成人伊人| av成人免费在线观看| 日本一区二区三区久久久久久久久不| 激情小说欧美图片| 精品少妇一区二区三区免费观看| 丝袜脚交一区二区| 欧美午夜精品免费| 亚洲成av人影院在线观看网| 91国偷自产一区二区使用方法| 1区2区3区欧美| 色综合天天综合| 亚洲色欲色欲www在线观看| 99久久精品国产导航| 中文字幕一区二区三区乱码在线| 成人黄色av网站在线| 国产精品久久久久久一区二区三区| 成人av在线播放网站| 国产精品无人区| 91影院在线观看| 亚洲视频一区二区免费在线观看 | av亚洲产国偷v产偷v自拍| 国产精品女主播av| 97国产一区二区| 一区二区三区在线免费播放| 欧美羞羞免费网站| 五月综合激情网| 精品精品国产高清a毛片牛牛| 激情国产一区二区| 中文字幕av不卡| 精品日韩一区二区| 国产成人在线视频免费播放| 国产日韩欧美精品在线| 成人精品视频一区二区三区| 国产精品福利一区二区| 欧洲一区在线电影| 日本亚洲三级在线| 欧美日韩欧美一区二区| 成人午夜电影小说| 五月婷婷另类国产| 欧美美女直播网站| 欧美日韩色一区| 日韩一区二区三区av| 日韩精品成人一区二区三区| 91麻豆精品国产自产在线观看一区| 三级欧美韩日大片在线看| 精品久久久久99| av中文字幕不卡| 天堂精品中文字幕在线| 国产婷婷精品av在线| 欧美最新大片在线看| 久久成人免费电影| 亚洲男同性视频| 欧美一二三区在线| 成人动漫精品一区二区| 日韩精品一二三四| 国产天堂亚洲国产碰碰| 欧美亚洲动漫精品| 国产精品一区2区| 亚洲国产成人tv| 欧美国产日韩一二三区| 欧美精品视频www在线观看| 国产aⅴ综合色| 亚洲高清中文字幕| 欧美激情一区不卡| 欧美一区二区日韩一区二区| 高潮精品一区videoshd| 奇米综合一区二区三区精品视频| 中文字幕精品—区二区四季| 555夜色666亚洲国产免| 成人精品亚洲人成在线| 男女性色大片免费观看一区二区 | 欧美在线制服丝袜| 国产精品综合视频| 日本aⅴ亚洲精品中文乱码| 国产精品乱码久久久久久 | 国产精品久久久久久久蜜臀| 91精品国产欧美日韩| 色成年激情久久综合| 成人免费毛片高清视频|