Advertisement
Ancurio

SFML (render) texture stats

Feb 3rd, 2013
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.44 KB | None | 0 0
  1. #define MCS(t) ((t).getElapsedTime().asMicroseconds())
  2. #define SAMPLE_SIZE 4
  3.  
  4.     sf::Clock timer;
  5.     sf::Texture *tex[SAMPLE_SIZE];
  6.     sf::RenderTexture *rtex[SAMPLE_SIZE];
  7.  
  8.     {
  9.         qDebug() << "Creating" << SAMPLE_SIZE << "512x512 RENDER textures";
  10.         for (int i = 0; i < SAMPLE_SIZE; i++)
  11.         {
  12.             timer.restart();
  13.             rtex[i] = new sf::RenderTexture();
  14.             rtex[i]->create(512, 512);
  15.             qDebug() << i << ":" << MCS(timer);
  16.         }
  17.         timer.restart();
  18.         for (int i = 0; i < SAMPLE_SIZE; i++)
  19.             delete rtex[i];
  20.         qDebug() << "Freeing took:" << MCS(timer) << "\n";
  21.     }
  22.  
  23.     {
  24.         qDebug() << "Creating" << SAMPLE_SIZE << "512x512 textures";
  25.         for (int i = 0; i < SAMPLE_SIZE; i++)
  26.         {
  27.             timer.restart();
  28.             tex[i] = new sf::Texture();
  29.             tex[i]->create(512, 512);
  30.             qDebug() << i << ":" << MCS(timer);
  31.         }
  32.         timer.restart();
  33.         for (int i = 0; i < SAMPLE_SIZE; i++)
  34.             delete tex[i];
  35.         qDebug() << "Freeing took:" << MCS(timer) << "\n";
  36.     }
  37.  
  38.     {
  39.         qDebug() << "Creating" << SAMPLE_SIZE << "512x512 textures AND render textures, interleaved";
  40.         for (int i = 0; i < SAMPLE_SIZE; i++)
  41.         {
  42.             timer.restart();
  43.             tex[i] = new sf::Texture();
  44.             tex[i]->create(512, 512);
  45.             qDebug() << "tex " << i << ":" << MCS(timer);
  46.  
  47.             timer.restart();
  48.             rtex[i] = new sf::RenderTexture();
  49.             rtex[i]->create(512, 512);
  50.             qDebug() << "rtex" << i << ":" << MCS(timer);
  51.         }
  52.         timer.restart();
  53.         for (int i = 0; i < SAMPLE_SIZE; i++)
  54.         {
  55.             delete tex[i];
  56.             delete rtex[i];
  57.         }
  58.         qDebug() << "Freeing took:" << MCS(timer) << "\n";
  59.     }
  60.  
  61.     {
  62.         qDebug() << "Creating" << SAMPLE_SIZE << "512x512 textures with immediate free";
  63.         for (int i = 0; i < SAMPLE_SIZE; i++)
  64.         {
  65.             timer.restart();
  66.             tex[i] = new sf::Texture();
  67.             tex[i]->create(512, 512);
  68.             qDebug() << i << ":" << MCS(timer);
  69.  
  70.             delete tex[i];
  71.         }
  72.         qDebug() << "\n";
  73.     }
  74.  
  75.     {
  76.         qDebug() << "Uploading 512x512 image data" << SAMPLE_SIZE << "times";
  77.         sf::Texture tex;
  78.         tex.create(512, 512);
  79.         sf::Image image;
  80.         image.loadFromFile("samples/512sample.png");
  81.         for (int i = 0; i < SAMPLE_SIZE; i++)
  82.         {
  83.             timer.restart();
  84.             tex.update(image);
  85.             qDebug() << i << ":" << MCS(timer);
  86.         }
  87.         qDebug() << "\n";
  88.     }
  89.  
  90.     {
  91.         qDebug() << "Downloading 512x512 image data" << SAMPLE_SIZE << "times";
  92.         sf::Texture tex;
  93.         tex.loadFromFile("samples/512sample.png");
  94.         for (int i = 0; i < SAMPLE_SIZE; i++)
  95.         {
  96.             timer.restart();
  97.             tex.copyToImage();
  98.             qDebug() << i << ":" << MCS(timer);
  99.         }
  100.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement