It is currently 19 Jun 2013, 20:57

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 27 posts ]  Go to page Previous  1, 2, 3
Author Message
 Post subject: Re: RCTools 4.3
PostPosted: 15 Apr 2011, 16:45 
Offline
Moderator
User avatar

Joined: 26 Sep 2009, 15:51
Posts: 782
Location: Bonn, Germany
Can't tell you what would actually run the fastest (which would probably be a big decision factor) - I'll do some tests.

Python would "sort of" make sense because I'm planing to use XPOP3 (written in python) for the popup (instead of the C++ MFC version)

_________________
Image rray.de, a resource site for softimage, updated apr 13th


Top
 Profile  
 
 Post subject: Re: RCTools 4.3
PostPosted: 15 Apr 2011, 16:56 
Offline
Administrator
User avatar

Joined: 04 Jun 2009, 12:15
Posts: 3242
I hope you decide on Python, otherwise I'd have to step down as a volunteer... ;)

_________________
"Forsan et haec olim meminisse iuvabit." (Virgil)


Top
 Profile  
 
 Post subject: Re: RCTools 4.3
PostPosted: 17 Apr 2011, 14:54 
Offline
Moderator
User avatar

Joined: 26 Sep 2009, 15:51
Posts: 782
Location: Bonn, Germany
Oh no x_x Python performs 30 times slower than JS in my tests.

I've written a simple triangle filter
(sources python/JS/VBS below -- For testing I used a polymsh sphere, local subd refinement, Doo-Sabin, Level 4)

Python Output:
Quote:
# Execution time : 3388.01209812 ms


JS Output:
Quote:
# INFO : Execution time : 113 ms


VBS Output:
Quote:
' INFO : Execution Time = 93,75 ms


Maybe it's the way I use the for loop in python that's wrong .. no idea @-)

C++ test still to go...

btw (from RCTools):

C# Output:
Quote:
// INFO : Execution time : 576 ms



Code:
import win32com.client

# Import the constants
from win32com.client import constants
from time import *

null = None
false = 0
true = 1

def XSILoadPlugin( in_reg ):
   in_reg.Author = "Ray"
   in_reg.Name = "PyBench Plug-in"
   in_reg.Major = 1
   in_reg.Minor = 0

   in_reg.RegisterFilter("PyBench", constants.siFilterSubComponentPolygon)
   #RegistrationInsertionPoint - do not remove this line

   return true

def XSIUnloadPlugin( in_reg ):
   strPluginName = in_reg.Name
   Application.LogMessage(str(strPluginName) + str(" has been unloaded."),constants.siVerbose)
   return true

# Match callback for the PyBench custom filter.
def PyBench_Match( in_ctxt ):
   Application.LogMessage("PyBench_Match called", constants.siVerbose)

#    Return value indicates if the input object matches the filter criterias.
   return true

# Subset callback for the PyBench custom filter.
def PyBench_Subset( in_ctxt ):
   Application.LogMessage("PyBench_Subset called", constants.siVerbose)

   start = clock()
   
   items = []   
   coll = XSIFactory.CreateObject("XSI.Collection")
   in_objs = in_ctxt.GetAttribute("Input")
   
   for obj in in_objs:
      subc = obj.SubComponent
      cc = subc.ComponentCollection         

      for poly in cc:
         if poly.Points.Count < 4:
            items.append(poly.Index)   
            
      oGeo = subc.Parent3DObject.ActivePrimitive.GetGeometry2( 0, constants.siConstructionModeSecondaryShape )
      coll.Add( oGeo.CreateSubComponent("poly", items) )
      
   in_ctxt.SetAttribute("Output", coll)
   
   end = clock()
   print("Execution time : " + str(1000*(end - start)) + " ms")
   
   return true

# Init callback for the PyBench custom filter.
def PyBench_Init( in_ctxt ):
   Application.LogMessage("PyBench_Init called", constants.siVerbose)

   return true



Code:
function XSILoadPlugin( in_reg )
{
   in_reg.Author =  "Ray";
   in_reg.Name = "JSBench Plug-in";
   in_reg.Major = 1;
   in_reg.Minor = 0;

   in_reg.RegisterFilter("JSBench",siFilterSubComponentPolygon);
   //RegistrationInsertionPoint - do not remove this line

   return true;
}

function XSIUnloadPlugin( in_reg )
{
   var strPluginName;
   strPluginName = in_reg.Name;
   Application.LogMessage(strPluginName + " has been unloaded.",siVerbose);
   return true;
}

// Match callback for the JSBench custom filter.
function JSBench_Match( in_ctxt )
{
   Application.LogMessage("JSBench_Match called",siVerbose);

//    Return value indicates if the input object matches the filter criterias.
   return true;
}

// Subset callback for the JSBench custom filter.
function JSBench_Subset( in_ctxt )
{
   Application.LogMessage("JSBench_Subset called");
   
   var start = new Date().getTime();
      
   coll = new ActiveXObject("XSI.Collection");
   
   in_objs = in_ctxt.GetAttribute("Input");
   
   jsA = new Array();

   e = new Enumerator(in_objs);
   for(; !e.atEnd(); e.moveNext())
   {
      logmessage(e.item().type);
      subc = e.item().SubComponent;
      cc = subc.ComponentCollection;

      e2 = new Enumerator(cc);      
      for(; !e2.atEnd(); e2.moveNext()) {
         if(e2.item().Points.Count < 4)
            jsA.push(e2.item().Index);
      }
   
      oGeo = subc.Parent3DObject.ActivePrimitive.GetGeometry(0, siConstructionMode.siConstructionModeSecondaryShape);
      coll.Add( oGeo.CreateSubComponent("poly", jsA) );
   }

   in_ctxt.SetAttribute("Output", coll);
   
   var end = new Date().getTime();
   logmessage("Execution time : " + eval(end - start) + " ms");
   
//    Return value indicates if a subset of the input objects matches the filter criterias.
   return true;
}

// Init callback for the JSBench custom filter.
function JSBench_Init( in_ctxt )
{
   Application.LogMessage("JSBench_Init called",siVerbose);

   return true;
}


Code:
function XSILoadPlugin( in_reg )
   in_reg.Author = "Ray"
   in_reg.Name = "VBBench Plug-in"
   in_reg.Major = 1
   in_reg.Minor = 0

   in_reg.RegisterFilter "VBBench",siFilterSubComponentPolygon
   'RegistrationInsertionPoint - do not remove this line

   XSILoadPlugin = true
end function

function XSIUnloadPlugin( in_reg )
   dim strPluginName
   strPluginName = in_reg.Name
   Application.LogMessage strPluginName & " has been unloaded.",siVerbose
   XSIUnloadPlugin = true
end function

' Match callback for the VBBench custom filter.
function VBBench_Match( in_ctxt )
   Application.LogMessage "VBBench_Match called",siVerbose   
   
'    Return value indicates if the input object matches the filter criterias.
   VBBench_Match = true
end function

' Subset callback for the VBBench custom filter.
function VBBench_Subset( in_ctxt )
   Application.LogMessage "VBBench_Subset called",siVerbose

   start = timer
   
   set coll = CreateObject( "XSI.Collection" )
   
   set in_objects = in_ctxt.GetAttribute( "Input" )

   for each obj in in_objects
      ' get the edge object(s) from the subcomponent
      set subc = obj.SubComponent

      dim aIndices
      nb_indices = 0
      
      l_Array = subc.ElementArray
      set l_Comps = subc.ComponentCollection
      
      ReDim aIndices( ubound(l_Array) - lbound(l_Array) )
      
      for each ply in l_Comps
         if ply.Points.Count < 4 then
            aIndices(nb_indices) = ply.Index
            nb_indices = nb_indices + 1      
         end if
      next
      
      if nb_indices > 0 then
         ReDim Preserve aIndices( nb_indices - 1 )
         set oSubComponent = subc.Parent3DObject.activeprimitive.geometry.CreateSubComponent("poly", aIndices )
         coll.Add oSubComponent
      end if   
   next
   
   in_ctxt.SetAttribute "Output", coll

   endt = timer
   
   LogMessage "Execution Time = " & 1000*(endt-start) & " ms"

   VBBench_Subset = coll.Count > 04
end function

' Init callback for the VBBench custom filter.
function VBBench_Init( in_ctxt )
   Application.LogMessage "VBBench_Init called",siVerbose

   VBBench_Init = true
end function

_________________
Image rray.de, a resource site for softimage, updated apr 13th


Top
 Profile  
 
 Post subject: Re: RCTools 4.3
PostPosted: 20 Apr 2011, 00:20 
Offline
Moderator
User avatar

Joined: 26 Sep 2009, 15:51
Posts: 782
Location: Bonn, Germany
Well ok I looks like I won't be able to get python to perform any faster with this - I guess I'm going to do aport to VBS then - seems not like too much work except changing some syntax.

VBS seems the closest to Softimage's internal architecture. JScript probably is, too (COM Version) except the arrays are different and some translation there has to be done which makes it a little slower than VBS.

_________________
Image rray.de, a resource site for softimage, updated apr 13th


Top
 Profile  
 
 Post subject: Re: RCTools 4.3
PostPosted: 20 Apr 2011, 10:30 
Offline

Joined: 11 Jun 2009, 09:13
Posts: 94
Python's loops seems to be lot slower in Softimage than the others...


Top
 Profile  
 
 Post subject: Re: RCTools 4.3
PostPosted: 08 May 2011, 11:09 
Offline
Administrator
User avatar

Joined: 04 Jun 2009, 12:15
Posts: 3242
Moderator edit: I moved the announcement for RCTools 4.4 to a new thread

_________________
"Forsan et haec olim meminisse iuvabit." (Virgil)


Top
 Profile  
 
 Post subject: Re: RCTools 4.3
PostPosted: 17 Oct 2012, 21:43 
Offline

Joined: 24 Sep 2010, 18:28
Posts: 595
rray wrote:
Oh no x_x Python performs 30 times slower than JS in my tests.

I've written a simple triangle filter
(sources python/JS/VBS below -- For testing I used a polymsh sphere, local subd refinement, Doo-Sabin, Level 4)

Python Output:
Quote:
# Execution time : 3388.01209812 ms


ROFL

Python is not slow, it's fucking Microsoft COM converting list to COM VARIANT so long for some reason (remove list conversion at the end and you'll see):

Code:
import win32com.client

from win32com.client import constants as c
from time import *

start = clock()

coll = XSIFactory.CreateObject("XSI.Collection")

obj = Application.Selection(0)

subc = obj.SubComponent
cc = subc.ComponentCollection         

items = (poly.Index for poly in cc if poly.Points.Count < 4)

end = clock()
print("Execution time : " + str(1000*(end - start)) + " ms")

oGeo = subc.Parent3DObject.ActivePrimitive.GetGeometry2( 0, c.siConstructionModeSecondaryShape )
coll.Add( oGeo.CreateSubComponent("poly", list(items)) )



_________________
Constantine
Learnable Programming


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 27 posts ]  Go to page Previous  1, 2, 3

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group