Hi,

I can't figure why the test program is crashing. I am comparing speeds of boost::python::tuple and boost::any as variable length application message wrappers.
////////////////////////////////////////////////
#include "boost//any.hpp"
#include "boost//python.hpp"
#include <string>
#include <vector>
// RakNet::GetTime for accurate millisecond timimg
#include "GetTime.h"
#include <stdio.h>
#include <iostream>
using namespace std;

void HandleBoostAny( const vector<boost::any>& ba)
{
   const string s = boost::any_cast<string>(ba[0]);
   const float f = boost::any_cast<float>(ba[1]);
   const int ui = boost::any_cast<int>(ba[2]);
}
void HandleBoostPythonTuple( const boost::python::tuple& b)
{
   const string s = boost::python::extract<std::string>(b[0]);
   const float f = boost::python::extract<float>(b[0]);
   const int ui = boost::python::extract<int>(b[2]);
}
int _tmain(int argc, _TCHAR* argv[])
{
   int count = 0;
   int target = 100000;
   string s = "spam";
   unsigned char i = 42;
   float f = 3.14f;

   //cout << "Starting boost.any test" << endl;
   //RakNetTime baStart = RakNet::GetTime();
   //for ( count = 0; count < target; ++count )
   //{
   //    vector<boost::any> ba;
   //    ba.push_back(boost::any(s));
   //    ba.push_back(boost::any(f));
   //    ba.push_back(boost::any(i));
   //    HandleBoostAny(ba);
   //}
   //RakNetTime baEnd = RakNet::GetTime();
   //cout << "Duration: " << (baEnd - baStart) << endl;
   ////////////////////////
   cout << "Starting boost.python.tuple test" << endl;
   RakNetTime bptStart = RakNet::GetTime();
   for ( count = 0; count < target; ++count )
   {
       boost::python::tuple bpt = boost::python::make_tuple(s,f);

       HandleBoostPythonTuple(boost::python::make_tuple(f));
   }
   RakNetTime bptEnd = RakNet::GetTime();
   cout << "Duration: " << (bptEnd - bptStart) << endl;
   return 0;
}
////////////////////////////////////////////////////

I am getting an access violation here, on WinXP SP3, boost 1.38:

python25.dll!1e07de69() [Frames below may be incorrect and/or missing, no symbols loaded for python25.dll] > speedTest.exe!boost::python::converter::arg_to_python<int>::arg_to_python<int>(const int & x=0) Line 113 + 0x31 bytes C++ speedTest.exe!boost::python::api::object_initializer_impl<0,0>::get<int>(const int & x=0, boost::mpl::bool_<0> __formal={...}) Line 374 + 0xf bytes C++ speedTest.exe!boost::python::api::object_base_initializer<int>(const int & x=0) Line 296 + 0x10 bytes C++ speedTest.exe!boost::python::api::object::object<int>(const int & x=0) Line 316 + 0x2c bytes C++ speedTest.exe!boost::python::api::object_operators<boost::python::api::object>::operator[]<int>(const int & key=0) Line 53 + 0xf bytes C++ speedTest.exe!HandleBoostPythonTuple(const boost::python::tuple & b={...}) Line 21 + 0x27 bytes C++
    speedTest.exe!main()  Line 59 + 0x35 bytes    C++
    speedTest.exe!__tmainCRTStartup()  Line 586 + 0x19 bytes    C
    speedTest.exe!mainCRTStartup()  Line 403    C
kernel32.dll!7c817077()
I can use make tuple in other programs, but cant see why not here.

Thanks for any advice

Simon
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to