ThomThom's Website

The Blog is Dead! Long live the Blog!

16 Apr 12 - 11:25
I'm closing down this old blog. Posts will be up, but I will not make new posts. Instead I will make use of my new WordPress powered blog: [www.thomthom.net]

Sketchup Vertex.position speed performance

11 Apr 10 - 18:44

I did some tests to investigate the performance of Vertex.position. The test setup:

> model = Sketchup.active_model
> sel = model.selection
> v1, v2 = sel[0].vertices
> p1, p2 = v1.position, v2.position

The first tests is a simple loop repeating a million times.


> t = Time.now; 1000000.times { v1.position }; puts Time.now - t
1.351

> t = Time.now; 1000000.times { p1 }; puts Time.now - t
0.1

As you can see, the performance hit of calling Vertex.position is significant.


> t = Time.now; 1000000.times { v1.position.distance(v2.position) }; puts Time.now - t
3.675

This is worst case scenario.


> t = Time.now; 1000000.times { v1.position.distance(v2) }; puts Time.now - t
2.705

Note that this passes a Vertex object to Point3d.distance instead of a Point3d object which the manual appear to indicate is the only option. As it turns out, you can pass the Vertex object directly and gain one speed improvement.


> t = Time.now; 1000000.times { v1.position.distance(p2) }; puts Time.now - t
2.445

But it's still not as fast as using a cache variable of Vertex.position.


> t = Time.now; 1000000.times { p1.distance(p2) }; puts Time.now - t
1.205

By far the fastest is to use only Point3d objects.

The conclusion is that you should cache the result of Vertex.position if you will be using the position multiple times.

And if you can not cache, then remember that many functions that takes a Point3d object as argument will also accept a vertex object which will be faster.

LULT - Sidebar - Changelog

19 Apr 08 - 14:58

Note: this is not an official gadget from Transport For London, so don't ask them for support.

Attention! This blog is no longer maintained. Information and updates will be posted at the new blog.

If you find any bugs, issues or simply got a feature suggestion, please contact me.

Attention Internet Explorer users! IE will incorrectly try to download the .gadget file as .zip from my server. If that happens rename the .zip file to .gadget. Alternatively you can download from one of the mirrors. I'll try to find a fix for this. —17 July 2008

Version 1.4.4 — 22.09.2010
Patch addressing IE9 compatibility.
Version 1.4.3 — 24.05.2010
Patch addressing the changes in the TFL source data.
Version 1.4.2 — 20.04.2010
Patch for unexpeccted formatting of the HTML source data.
Version 1.4.1 — 18.04.2010
Patch for lines with multiple statuses and fixed the update message.
Version 1.4.0 — 18.04.2010
New parsing engine in an attempt to avoid failure due to HTML errors from the TFL data.
Version 1.3.15 — 01.12.2008
Hotfix to address parsing error.
Version 1.3.14 — 26.11.2008
Hotfix to account for TFL source. (The source has been changed significantly, so please report back if you see times when you're missing info.)
Version 1.3.13 — 25.10.2008
Hotfix that restore the update notifier.
Version 1.3.12 — 12.10.2008
Hotfix to provide all information for the detail flyout window and not just the last item.
Version 1.3.11 — 31.08.2008
Added a temporary fix to allow users to refresh data after resuming the computer from sleep or hybernation and the gadget tried to access the internet before the network connections are back online.
Version 1.3.10 — 25.06.2008
Fixed: forgot to enable the update checker.
Version 1.3.9 — 24.06.2008
Intermediate release before 1.4 to address changes in the TFL source which broke the parser.
Version 1.3.0 — 28.03.2008
Added option to select what lines to monitor.
Version 1.2.1 — 27.06.2007
Small tweak to account for change in the sourcecode at TFL.
Version 1.2.0 — 09.04.2007
Because of all the updates and paches I've had to do I added an update notification system to the gadget. Hope this will make things easier.
Version 1.1.0 — 09.04.2007
Finally updated the graphics and added an undocked mode.
Version 1.0.3 — 02.04.2007
Again the format on the TFL site changed. I've contacted them asking of there's any chance they'll provide the data in XML format. Waiting for a reply. Until then, all I can do is make these patches.
Version 1.0.2 — 28.03.2007
Sorry, yet another update. The source file at the TFL site has been a bit unpredictable after the update. I'm looking into finding a more reliable way of getting the data.
Version 1.0.1 — 26.03.2007
Sorry. I screwed up the packaging of the gadget. Think I included the old file.
Version 1.0.1 — 25.03.2007
Emergency patch to account for TFL site change.

Standalone gadget for Windows 2000 or newer: Download

Document History Viewer – Making use of <del> and <ins>

22 Mar 08 - 12:57

I put together some quick examples to how <del> and <ins> can be used. It’s some of the HTML tags which doesn’t seem to get used allot.

Using jQuery I built a crude Document History Viewer. It’s basically a time machine for HTML documents where you can read the document as it where on a previous date.

The first example document simply displays some dummy text where I’ve added some <ins> and <del>. It’s the change log for the Colour Swatch gadget I made. The <ins> and <del> here are just added randomly. However, a change log is a good example where <ins> and <del> is useful to allow the user to read through the various changes to the product.

The second example shows how it can be used to present source code where you can see the various changes made to it. If you click on one of the changes you will get the time and date of the change along with the title all extracted from the <ins> or <del> element itself. It also present the cite URL and uses AJAX to fetch the extended information about the reason for the edit.

The third and final example is just a test to see how browsers dealt with ordered lists as <ins> and <del> was dynamically hidden and displayed. It appears to work fine. Only issue is that the <del> and <ins> has to wrap around the <li> element and this is not valid according to the W3Cspecifications. However, I see this as a flaw in the specifications and I think it’s OK to break it.

If you have some creations using <del> and <ins> I’d like to see it. It’s a set of HTML elements which adds good semantic value to a document, but is rarely used. The jQuery script in the examples are not the best. They are hacked and bashed as the requirement to it changes as I was experimenting. But if you find any use for it, feel free to use it.

<del> and <ins> in lists

22 Mar 08 - 12:16

While working on some examples to demonstrate <ins> and <del> with a document history viewer I came across an unexpected problem. If you want to remove or insert a whole list item, you can’t wrap it in <del> or <ins> as <ul> and <ol> only allows <li> children.

Putting <del> inside the <li> makes the browsers render the list item as it was empty but with the bullet, leaving an undesired result if you have set del { display: hidden; }.

This appears to be a case where the specifications haven’t taken into account every option. If you remove a list item at some point and would like to mark that up in your HTML document then you want to mark up the entire list item, including the <li> tag, not just it content.

Fortunately, it looks like all browsers will render <del><li>Lorem Ipsum</li></del> as I want, removing the entire list item including the bullet. This is invalid markup according to the specifications, but I think that this is a good example of where you can ignore that.

I posted a comment about this in the public W3C HTML news group. Hoping that it’d be added to the HTML5 specifications. So far there’s no response.

More Posts

Newest | Newer | 1 | 2 | 3 | 4 | Older | Oldest