[Liblas-commits] laszip: quitting random seek loop after 100 seeks

liblas-commits at liblas.org liblas-commits at liblas.org
Wed May 11 19:36:40 EDT 2011


details:   http://hg.liblas.orglaszip/rev/22d8d441f1a6
changeset: 234:22d8d441f1a6
user:      isenburg
date:      Wed May 11 16:34:07 2011 -0700
description:
quitting random seek loop after 100 seeks
Subject: laszip: merge

details:   http://hg.liblas.orglaszip/rev/484b68b9d852
changeset: 235:484b68b9d852
user:      isenburg
date:      Wed May 11 16:38:59 2011 -0700
description:
merge

diffstat:

 tools/laszippertest.cpp |  505 ++++++++++++++++++++++++-----------------------
 1 files changed, 255 insertions(+), 250 deletions(-)

diffs (truncated from 599 to 300 lines):

diff -r 8bd0e8d832dc -r 484b68b9d852 tools/laszippertest.cpp
--- a/tools/laszippertest.cpp	Tue May 10 07:35:16 2011 -0700
+++ b/tools/laszippertest.cpp	Wed May 11 16:38:59 2011 -0700
@@ -157,7 +157,7 @@
   };
 
   bool m_use_iostream;
-  const char* m_filename;
+  const char* m_filename;
   FILE* ifile;
   filebuf ifb;
 #ifdef LZ_WIN32_VC6 
@@ -175,37 +175,37 @@
 public:
   PointData(unsigned char type=5, unsigned short size=70)
   {
-    point_type = type;
-    point_size = size;
-    point = 0;
-    point_data = 0;
-  }
+    point_type = type;
+    point_size = size;
+    point = 0;
+    point_data = 0;
+  }
 
-  bool PointData::setup(unsigned int num_items, const LASitem* items)
-  {
-    unsigned int offset = 0;
-    if (point) delete [] point;
-    point = new unsigned char*[num_items];
-    if (point_data) delete [] point_data;
-    point_data = new unsigned char[point_size];
-    for (unsigned int i = 0; i < num_items; i++)
-    {
-      point[i] = &(point_data[offset]);
-      offset += items[i].size;
-    }
-    return (offset == point_size);
+  bool setup(unsigned int num_items, const LASitem* items)
+  {
+    unsigned int offset = 0;
+    if (point) delete [] point;
+    point = new unsigned char*[num_items];
+    if (point_data) delete [] point_data;
+    point_data = new unsigned char[point_size];
+    for (unsigned int i = 0; i < num_items; i++)
+    {
+      point[i] = &(point_data[offset]);
+      offset += items[i].size;
+    }
+    return (offset == point_size);
   }
 
   ~PointData()
   {
-    if (point) delete [] point;
-    if (point_data) delete [] point_data;
+    if (point) delete [] point;
+    if (point_data) delete [] point_data;
   }
 
-  unsigned char point_type;
+  unsigned char point_type;
   unsigned short point_size;
   unsigned char** point;
-  unsigned char* point_data;
+  unsigned char* point_data;
 };
 
 
@@ -268,16 +268,16 @@
     log("ERROR: could not make laszipper\n");
     exit(1);
   }
-  int stat = 0;
-  if (ost->m_use_iostream)
-    stat = zipper->open(*ost->streamo, laszip);
-  else
-    stat = zipper->open(ost->ofile, laszip);
-  if (stat != 0)
-  {
-    log("ERROR: could not open laszipper with %s\n", ost->m_filename);
-    exit(1);
-  }
+  int stat = 0;
+  if (ost->m_use_iostream)
+    stat = zipper->open(*ost->streamo, laszip);
+  else
+    stat = zipper->open(ost->ofile, laszip);
+  if (stat != 0)
+  {
+    log("ERROR: could not open laszipper with %s\n", ost->m_filename);
+    exit(1);
+  }
   return zipper;
 }
 
@@ -291,16 +291,16 @@
     log("ERROR: could not make lasunzipper\n");
     exit(1);
   }
-  int stat = 0;
-  if (ist->m_use_iostream)
-    stat = unzipper->open(*ist->streami, laszip);
-  else
-    stat = unzipper->open(ist->ifile, laszip);
-  if (stat != 0)
-  {
-    log("ERROR: could not open laszipper with %s\n", ist->m_filename);
-    exit(1);
-  }
+  int stat = 0;
+  if (ist->m_use_iostream)
+    stat = unzipper->open(*ist->streami, laszip);
+  else
+    stat = unzipper->open(ist->ifile, laszip);
+  if (stat != 0)
+  {
+    log("ERROR: could not open laszipper with %s\n", ist->m_filename);
+    exit(1);
+  }
   return unzipper;
 }
 
@@ -378,7 +378,7 @@
     srand(settings->seed);
     c = rand() % 256;
     for (i = 0; i < settings->num_points; i++)
-    {
+    {
       unzipper->read(data.point);
       for (j = 0; j < data.point_size; j++)
       {
@@ -419,7 +419,7 @@
 
   if (num_errors)
   {
-    log("ERROR: with lasunzipper %d\n", num_errors);
+    log("ERROR: with lasunzipper %d\n", num_errors);
     getc(stdin);
   }
   else
@@ -433,215 +433,220 @@
 
 //---------------------------------------------------------------------------
 
-//---------------------------------------------------------------------------
-
-static void write_points_seek(LASzipper* zipper, PointData& data)
-{
-  if (zipper==NULL)
-    return;
-
-  double start_time, end_time;
-  unsigned char c;
-  unsigned int i,j;
-  unsigned int num_bytes;
-
-  start_time = taketime();
-
-  // the two branches of this IF are the same, except for the use of a random number;
-  // we keep the random case separate, so that we can get fastest timing tests w/o random data
-  if (settings->use_random)
-  {
-    for (i = 0; i < settings->num_points; i++)
-    {
-      srand(i);
-      c = rand() % 256;
-      for (j = 0; j < data.point_size; j++)
-      {
-        data.point_data[j] = c;
-        c = rand() % 256;
-      }
-      zipper->write(data.point);
-    }
-    num_bytes = zipper->close();
-  }
-  else
-  {
-    for (i = 0; i < settings->num_points; i++)
-    {
-      c = (unsigned char)i;
-      for (j = 0; j < data.point_size; j++)
-      {
-        data.point_data[j] = c;
-        c++;
-      }
-      zipper->write(data.point);
-    }
-    num_bytes = zipper->close();
-  }
-
-  end_time = taketime();
-
-  log("laszipper wrote %u bytes in %g seconds\n", num_bytes, end_time-start_time);
-
-  return;
-}
-
-//---------------------------------------------------------------------------
-
-static void read_points_seek(LASunzipper* unzipper, PointData& data)
-{
-  if (unzipper==NULL)
-    return;
-
-  unsigned char c;
-  unsigned int i,j;
-  unsigned int num_errors, num_bytes;
-  double start_time, end_time;
-
-  start_time = taketime();
-  num_errors = 0;
-
-  if (settings->use_random)
-  {
-    for (i = 0; i < settings->num_points; i++)
-    {
-      if (i%1000 == 0)
-      {
-        int s = (rand()*rand())%settings->num_points;
-        fprintf(stderr, "at position %d seeking to %d\n", i, s);
-        unzipper->seek(s);
-        i = s;
-      }
-      unzipper->read(data.point);
-      srand(i);
-      c = rand() % 256;
-      for (j = 0; j < data.point_size; j++)
-      {
-        if (data.point_data[j] != c)
-        {
-          log("%d %d %d != %d\n", i, j, data.point_data[j], c);
-          num_errors++;
-          if (num_errors > 20) break;
-        }
-        c = rand() % 256;
-      }
-      if (num_errors > 20) break;
-    }
-    num_bytes = unzipper->close();
-  }
-  else
-  {
-    for (i = 0; i < settings->num_points; i++)
-    {
-      if (i%1000 == 0)
-      {
-        int s = (rand()*rand())%settings->num_points;
-        fprintf(stderr, "at position %d seeking to %d\n", i, s);
-        unzipper->seek(s);
-        i = s;
-      }
-      unzipper->read(data.point);
-      c = (unsigned char)i;
-      for (j = 0; j < data.point_size; j++)
-      {
-        if (data.point_data[j] != c)
-        {
-          log("%d %d %d != %d\n", i, j, data.point_data[j], c);
-          num_errors++;
-          if (num_errors > 20) break;
-        }
-        c++;
-      }
-      if (num_errors > 20) break;
-    }
-    num_bytes = unzipper->close();
-  }
-
-  end_time = taketime();
-
-  if (num_errors)
-  {
-    log("ERROR: with lasunzipper %d\n", num_errors);
-    getc(stdin);
-  }
-  else
-  {
-    log("SUCCESS: lasunzipper read %u bytes in %g seconds\n", num_bytes, end_time-start_time);
-  }
-
-  return;
-}
-
-//---------------------------------------------------------------------------
-
+//---------------------------------------------------------------------------
+
+static void write_points_seek(LASzipper* zipper, PointData& data)
+{
+  if (zipper==NULL)
+    return;
+
+  double start_time, end_time;
+  unsigned char c;
+  unsigned int i,j;
+  unsigned int num_bytes;


More information about the Liblas-commits mailing list