Notifications
Clear all

[Closed] Lambda Expressions in Maxscript – II

if you want to compare performance do it for this >> for example
>>


fn _three_arg_execute act a b c = (c = act a b c) 

(
	delete objects
	sp = converttomesh (geosphere())
	(
		t = timestamp()
		h = heapfree

		for k=1 to 10000 do
		(
			ii = #()
			_three_arg_execute (mapped fn'' i mesh list = (if (getvert mesh i).z < 0 do append list i; list)) (#{1..sp.numverts} as array) sp ii
		)

		format "<< time:% heap:%
" (timestamp() - t) (h - heapfree)
	)
	sp.selectedverts = ii
)

1 Reply
(@aaandres)
Joined: 11 months ago

Posts: 0

I’ve found another query method that is faster (see above).
With this method, here’s the comparison: time still good enough (x1,17) but huge memory usage (x11,32).
Your code:

(
	fn _three_arg_execute act a b c = (c = act a b c) 
	
	delete objects
	sp = converttomesh (geosphere())
	(
		t = timestamp()
		h = heapfree
		for k=1 to 10000 do
		(
			ii = #()
			_three_arg_execute (mapped fn'' i mesh list = (if (getvert mesh i).z < 0 do append list i; list)) (#{1..sp.numverts} as array) sp ii
		)
		format "<< time:% heap:%
" (timestamp() - t) (h - heapfree)
	)
)	

– << time:5338 heap:21.706.768L
Mine:

(
	delete objects
	sp = converttomesh (geosphere())
	(
		t = timestamp()
		h = heapfree
		for k=1 to 10000 do
		(
			QArray = ArrayQuery #(sp)
			ii = ((QArray.Change(#'node => for v = 1 to node.numverts collect (getvert node v)')).Change(#'verts => for v= 1 to verts.count where verts[v].z<0 collect v')).Select()
		)
		format "<< time:% heap:%
" (timestamp() - t) (h - heapfree)
	)
)	

– << time:6275 heap:245.760.120L
With the new ‘maxObjectQuery’ function

(
	delete objects
	sp = converttomesh (geosphere())
	(
		t = timestamp()
		h = heapfree
		for k=1 to 10000 do
		(
			QArray = ArrayQuery (#{1..sp.numverts} as array)
			ii = (QArray.maxObjectQuery sp (#'vert => (getvert obj vert).z < 0')).select()
		)
		format "<< time:% heap:%
" (timestamp() - t) (h - heapfree)
	)
)	

– << time:7255 heap:53.200.120L (time x1,36 and memory x2,45)

Page 2 / 2