performance,3dsmax,maxscript , Pass by value / reference performance comparison in Maxscript?

Pass by value / reference performance comparison in Maxscript?


Tag: performance,3dsmax,maxscript

How does it affect efficiency in Maxscript?. Maxscript is a slow one, but i wonder how much does it affect?

I tried this script, it took a lot of time to execute the operations in the array, but later on the call to functions were fast returning 0 to the time diference (i tried a very high item count in the array).

fn testear lista =
    a = 1 + 2

fn testear2 &lista =
    a = 1 + 2

fn inicio = 
    lista = #()

    for i = 1 to 1000000 do 
        append lista "hola"

    strTime = timeStamp()
    endTime = timeStamp()
    format "\ninicio % final % -> diferencia %\n" strTime endTime (endTime - strTime)

    strTime = timeStamp()
    endTime = timeStamp()
    format "\ninicio % final % -> diferencia %\n" strTime endTime (endTime - strTime)

    for i = 1 to lista.count do
        deleteItem lista 1




If you pass an array to a function it automatically gets passed as reference. Those two functions are doing the same thing. Try this:

fn test1 arr = (
  arr[1] = "test1"
fn test2 &arr = (
  arr[1] = "test2"
fn init = (
  testArray = #(1,2,3,4,5,6,7,8,9,0)
  format "Test #1: %\n" testArray
  test1 testArray
  format "Test #2: %\n" testArray
  test2 &testArray
  format "Test #3: %\n" testArray


Notice 'testArray' gets changed by the test functions and the change is reflected outside the test functions' scope.

However, array operations can take up a lot of time. When you append to an array, like you do in your code, it basically creates a copy of your array every time you add a new item.

A faster method would be to create an array the size you need initially:

lista[1000000] = ""
for i = 1 to 1000000 do 
  lista[i] = "hola"

Deleting every item in the array took the longest, but I don't think you need to do that. Maxscript does a lot of the garbage collection for you so when your script terminates it should free up that memory. Maybe you could try this:

for i = 1 to lista.count do
  lista[i] = undefined
lista = undefined

But again, I don't think it's necessary. You can call the built-in garbage collection function:


Hope that answers your question.


Speeding up a SQL query with indexes

I have a table called Products. This table contains over 3 million entries. Every day there are approximately 5000 new entries. which only happens during the night in 2 minutes. But this table gets queried every night maybe over 20 000 times with this query. SELECT Price FROM Products WHERE...

Reading from DATA file handle

My perl module needs to use a look up table that's about 309,000 lines long. Currently the part that loads the table into an array looks (roughly) like this: use strict; use warnings; # load all the data from below my @ref_data; while (<DATA>) { push @ref_data, $_ } close...

hadoop large file does not split

I have an input file of size 136MB and I launched some WordCount test and I monitor only one mapper. Then I set dfs.blocksize to 64MB in my hdfs-site.xml and I still get one mapper. Am I doing wrong ?

How to make this code more performant?

I have this snippet of code that iterate over a map and filter some fields based on relation type, I have to run two loops and have a feeling that it is going to be slow for big maps. Is there any way I can technique/refactoring to make this code...

DB Index not being called

I know this question has been asked more than once here. But I am not able to resolve my issue so posting it again for help. I have a table called Transaction in Oracle database (11g) with 2.7 million records. There is a not-null varchar2(20) (txn_id) column which contains numeric...

Ontologies, OWL, Sparql: Modelling that “something is not there” and performance considerations

we want to model that "something is not there" as opposed to missing information, e.g. an explicit statement that "a patient did not get chemotherapy" or that "a patient does not have dyspnea" is different from missing information about whether a patient has dyspnea. We thought about several approaches, e.g....

Pygame 3D: How to and is it possible?

So I want to program a 3d-mesh viewer in pygame, no other 3rd-party modules wanted (panda3d is perfect, but it's very complicated). My idea is: list_of_surfs = {'85 50':'70deg'} #the 85 50 and the dimensions of the #side/surf, and 70 deg of rotation to be able to see it, then...

SQL Server Query Performance with Timestamp and variable

I have a simple SQL query to count the number of telemetry records by clients within the last 24 hours. With an index on TimeStamp, the following query runs in less than 1 seconds for about 10k rows select MachineName,count(Message) from Telemetry where TimeStamp between DATEADD(HOUR,-24, getutcdate()) and getutcdate() group...

(Automatically) convert SQL strings to 'enums'?

We have a PostgreSQL database with billions of entries in the form: CREATE TABLE entry ( session integer NOT NULL, time integer NOT NULL, key text NOT NULL, data text NOT NULL ) In this database key is a developer-defined string, while data is user-defined content. In other words, while...

MySQL JOIN / IN performance optimization

I have a following MySQL query: SELECT p.post_id, p.date_created, p.description, p.last_edited,, p.link_description, p.link_image_url, p.link_title, p.total_comments, p.total_votes, p.type_id, p.user_id FROM posts p JOIN posts_to_tribes ptt ON p.post_id=ptt.post_id WHERE ptt.tribe_id IN (1, 2, 3, 4, 5) GROUP BY p.post_id ORDER BY p.last_edited DESC, p.total_votes DESC LIMIT 25 In a non-concurrent environment...

How to count the number of zero decimals in javascript?

How do I get the number of zero decimals behind the comma (but not the total)? So to illustrate an example: 0.00001 > 4 0.000015 > 4 0.0000105 > 4 0.001 > 2 I am looking for methods that are efficient (meaning that they optimize the calculation time)....

MySQL - How can I know my query is tuned?

I'm creating a DB from scratch and I'm trying to create queries with performance in mind. For test purpose I filled my tables with test data. My query needs to join 3 tables: 2 with millions of rows and the third with hundred thousands rows. How can I know my...

Fast access to matrix as jagged array in C#

I've created a lower triangular distance matrix (because of size issues) as jagged array Note: Distances between objects are symmetric var dm = new double[size][] for (var i = 0; i < size; i++) { dm[i] = new double[i+1]; for (var j = 0; j < i+1; j++) { dm[i][j]...

Insert multiple rows into MySQL table

I have a table as follows: CREATE TABLE IF NOT EXISTS mytable ( `id` INT(22) NOT NULL AUTO_INCREMENT, `name` VARCHAR(255) NOT NULL, `uuid` VARCHAR(255) NOT NULL, `x` INT(11) NOT NULL, `y` INT(11) NOT NULL, `z` INT(11) NOT NULL, `time` BIGINT NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY idx_table_x_y_z ( x,...

Can not increase max_open_files for Mysql max-connections in Ubuntu 15

I am running this version of Mysql Ver 14.14 Distrib 5.6.24, for debian-linux-gnu (x86_64) On this version of Ubuntu Distributor ID: Ubuntu Description: Ubuntu 15.04 Release: 15.04 Codename: vivid This is the config I set for Mysql: key_buffer_size = 16M max_allowed_packet = 16M thread_stack = 192K thread_cache_size = 8 innodb_buffer_pool_size=20G...

Prevent upvote model from being called for every comment

I have three models: User, Comment and Upvote. User-to-Comment has a one-to-many relation, Comment-to-Upvote has a one-to-many relation and User-to-Upvote has a one-to-many relation. I want to do something similar to the upvoting done on Stackoverflow. So when you upvote/downvote the arrow will highlight and remain highlighted even if you...

Fastest way to draw sprites in opengles 2.0 on android

So Im trying to figure out how to draw a single textured quad many times. My issue is that since these are create and deleted and every one of them has a unique position and rotation. Im not sure a vbo is the best solution as I've heard modifying buffers...

performance issues executing list of stored procedures

I'm having some performance issues when starting my windows service, the first round my lstSps is long (about 130 stored procedures). Is there anyway to speed this up (except for speeding the stored procedures up)? When the foreach is over and goes over to the second round it goes faster,...

Mysql query using subselects needs to use joins or exists

NOTE If your going to downvote my question that I clearly put a lot of time into, can you please at least tell me why so I can avoid any mistakes in the future? Thank you. Update At the suggestion of @DRapp I am adding an explanation as to what...

How to model data for in-memory processing

I have a lot of static data (i.e. read only data, which is not transactional) which gets updated only once in few days. I have to support searches on that data (api calls, not sql). So I am thinking I will just load it in Memory, and refresh the in-memory...

Javascript performance of indexing

Is the following line considered unoptimal, especially considering it is being used in many places or inside of a loop: var age = myObject[index]["Person"]["Identity"]["Bio"]["Age"] ...

Paste the elements of two columns [duplicate]

This question already has an answer here: Speedy/elegant way to unite many pairs of columns 3 answers I have a data.frame of the following kind set.seed(12) d = data.frame(a=sample(5,x=1:9), b=sample(5,x=1:9), c=sample(5,x=1:9), d=sample(5,x=1:9), e=sample(5,x=1:9), f=sample(5,x=1:9)) d # a b c d e f # 1 1 1 4 4 2...

Why does the java DirectoryStream perform so slow?

I've done some testing with Streams in special with DirectoryStreams of the nio-package. I simply try to get a list of all files in a directory sorted by last modified date and size. The JavaDoc of old File.listFiles() stated a Note to the method in Files: Note that the Files...

fast JQUERY SELECTOR for clicking

Do I need to wrap class elements by an id element for a big document? Is $('#id').find('.class').click faster than $('.class').click ? Also, I want to know. Is <a onclick="function()">link</a> faster than selector id link with $(selector).click?...

Ruby: How does loading of objects in batches improve memory usage?

I'm self taught and not too sure about the terminology or specific improvements there are (if any) from splitting up object loading into separate parts in a loop. For example, I use rails and recently I've encountered an issue where I was loading too many heavy ActiveRecord objects at once,...

Clustering a large, very sparse, binary matrix in R

I have a large, sparse binary matrix (roughly 39,000 x 14,000; most rows have only a single "1" entry). I'd like to cluster similar rows together, but my initial plan takes too long to complete: d <- dist(inputMatrix, method="binary") hc <- hclust(d, method="complete") The first step doesn't finish, so I'm...

Do you get the same performance using index prefixes?

Say I have a collection containing documents like the one below: { _id: ObjectId(), myValue: 123, otherValue: 456 } I then create like below: {myValue: 1, otherValue: 1} If I execute the following query: db.myCollection.find({myValue: 123}) will I get the same performance with my index as I would if I...

Unsafe, reflection access vs toCharArray (performance)

JDK9 team puts effort into helping us removing non-public dependencies (using jdeps). I am using Unsafe class for faster access to Strings inner char array - without creating new char array. If I want to drop dependency on Unsafe class, I would need to load it dynamically and call Unsafe.getObject...

OpenCV FAST corner detection SSE implementation walkthrough

Could someone help me understanding the SSE implementation of the FAST corner detection in OpenCV? I understand the algorithm but not the implementation. Could somebody walk me through the code? The code is long, so thank you in advance. I am using OpenCV 2.4.11 and the code goes like this:...

Messaging table performance - Merge from and to id`s into one single field vs separate 2 fields

What would be the implications on performance on merging the users id from the "messages" table in form of "fromto" - ex userID - 5, userID 9 => "59" versus having two separate columns "from" and "to"? Flow - list, read, delete messages when both id`s will be available in...

How does a servlet handle more bytes than available RAM?

Lets say that I have a servlet running that accepts files of any size from a client application(s). The file being sent is loaded into a DataHandler and is transmitted by web-services; as such is received and put back into a DataHandler. What happens if the file being sent exceeds...

R: Painfully slow read performance using RODBC & SQL Server

I am new to R but am interested in using Shiny to create dynamic charts using data stored in a SQL Server database. To enable interactivity, I want to bring in the raw data from the database and perform calculations within R rather than have the database summarize the data....

Dynamic creation of objects vs storing them as fields

I have this loop which runs about 1,000,000 times. while ((line = br.readLine()) != null) { if(!(line.isEmpty())){ data = new JSONObject(line); name = (String)data.get("name"); surname = (String)data.get("surname"); ar.put(name, surname); //an array } } What are the advantages (if any) in terms of efficiency of having it like that were data,name...

How to print iterations per second?

I have a small Python script which sends POST requests to a server and gets their response. It iterates 10000 times, and I managed to print the current progress in command prompt using: code=current_requestnumber print('{0}/{1}'.format(str(code),"10000"),end="\r") at the end of each loop. Because this involves interaction with a webserver, I would...

Synchronize local SQLite database with central database

We are developing an Android App based on a product that already has a website. As a result, when launching the Android app it may happen that a lot of things differ between the local SQLite database and our central database. What is the fastest way to synchronize the Android...

Android: Is this method always available and present?

I want to make the most out root access to all folders. this order is correct and always available and present? File ffile = new File(Environment.getRootDirectory().getParent()); // return "/" // "/" out root access to all folders ...

Load js files from the web or serve them yourself?

I have had this question for awhile and am surprised that I have yet to come across a good/complete answer to it. The question is essentially this: When it comes to loading js files, in what situations should you load them from the web if available versus serving them up...

Compare multi values against multi values, maintaining performance

I have two forms of records or data. One being Inventory Record and the other a Product. Both the Inventory Record and Product Record have Code values stored in separate tables. Each record has a value record and is foreign keyed to the main table. I am trying NOT to...

What would be the fastest way to insert this data

Okay, so I have a MySQL table called entries which contains the columns name VARCHAR(255) NOT NULL and address VARCHAR(255) The table has about a million sets of data. For every set of data, name has a value e.g. "john" whilst address is NULL. For example: +------+---------+ | name |...

Angular ng-repeat cache (avoid re-rendering on state change)

We have huge rendering spikes with ng-repeat in Angular application. Main page shows a huge list of cover images ("::" and "track by" are in place). On first load it works acceptable. But if user changes the state (we use UI-Router) and goes back to the home page afterwards then...

Performance degradation of fast-serialization

This question is particular to the Fast-Serialization library. I am using FSTLongOffheapMap (version 2.29) on windows 7, jdk 1.7 to store some objects. I tested the latency of storing an object and the 99.99 percentile comes to about 100 micros. This is excellent considering I ran it on windows...

Universal function for getting all unique pairs, trebles etc from an array in javascript

I am looking to create a function in javascript, which would allow me to pass a long array, together with one argument. what I'm looking for is something like this: var ar = [1,2,3,4]; var pairs = superAwesomeFunction(ar,2) //=> [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]; var trebles = superAwesomeFunction(ar,3) //=> [[1,2,3],[1,2,4],[1,3,4],[2,3,4] ideally, the function would...

Performance difference between pattern matching and if-else

Why can OCaml generate efficient machine code for pattern matching and not for if-else tests? I was reading Real World OCaml and I came across this section where they compared the performance of pattern matching to the performance of if-else tests. It turned out that pattern matching in their example...

What is difference between join syntax in T-SQL [duplicate]

This question already has an answer here: ANSI vs. non-ANSI SQL JOIN syntax 6 answers This is my SQL query: SELECT last_name, department_name FROM employees e, departments d WHERE e.department_id = d.department_id; And: SELECT last_name, department_name FROM employees e INNER JOIN departments d ON e.department_id = d.department_id; What is...

ICorProfilerCallback2: CLR profiler does not log all Leave calls

I am trying to write a profiler that logs all .Net method calls in a process. The goal is to make it highly performant and keep let's say the last 5-10 minutes in memory (fixed buffer, cyclically overwrite old info) until the user triggers that info to be written to...

performance of executing openjpa query

I have a rest web app with cxf 3.0.1 framework and openjpa 2.3.0. The web.xml: <web-app xmlns="" xmlns:xsi="" xsi:schemaLocation=""> <display-name>Mobile app rest services</display-name> <context-param> <param-name>contextConfigLocation</param-name> <param-value>WEB-INF/cxf-servlet.xml</param-value>...

microtime(true) - Trouble measuring PHP script execution time

While trying to compare algorithm running time in PHP, I came across the microtime() function. But I think there's something fundamental I've missed in understanding. The difference of two microtime(true) calls returns the result in seconds, right? Then consider this extremely simple script: $t1 = microtime(true); //do nothing $t2 =...

MySQL COUNT vs SELECT rows performance

I have a small table with three columns and using PHP. TABLE (id unsigned int(10), gameid unsigned int(10), userid unsigned int(10)) - id, gameid and userid are indexed. At some point (When a player join a game) system will check if the game already have 100 players in it, if...

Should I pass all the state in every change from store to component?

I am new on React and Flux and I am making an app that will have an input (like the name or the title), and below a list of n things. How should I handle the event listeners? I saw in the TODO example of flux ( that they use...

Best data type for list of ?

What's the best data type performance-wise for a list of tuples composed of <ID, object>, such that the IDs are not unique? For example: 1 tire 1 rim 1 spoke 2 buckle 2 flap 2 bag What would give the best performance when selecting for ID = 1? I have...