S# 2.0 features. It’s all about performance, dynamics and integration.


In this article I would like to give you some details towards next version (2.0) of the S# language and scripting runtime.

Version 2.x will be based on .NET 4.0 and will be supported separately of Version 1.x that is still built on the top of .NET 3.5. Both versions will have a set of common features powered by both .NET 3.5 and .NET 4.0 however version 2.x will introduce a set of brand new capabilities built on the top of .NET 4.0 only. The entire 2.x family will be backward compatible. There will be no breaking changes in the scripts and migration difficulties.

Performance

A lot of work is related to script execution performance. S# runtime is used in various reporting and visualization tools where execution time of large or repetitive blocks is very important. Version 2 provides tremendous improvements and optimizations in comparison to Version 1.0.

Here’s one of our comparison benchmarks for basic loops (execution results are given in milliseconds)

Script v.1 v.2 %
for (i = 0; i <= 100000; i++) { } 48.7 26.7 182
for (i = 0; i <= 100000; i = i + 1) { } 63.84 41.38 154
for (i = 0; i <= 100000; i++) {  i.ToString(); } 4129.5 227.06 1517
a = [1,2,3]; x = 0; for (i = 0; i < 100000; i++) { x = a[1]; } 1571.1 72.62 2164
a = [1,2,3]; for (i = 0; i < 100000; i++) { a[0] = i; } 2630.9 87.38 3011
x = null; p = new Person(); for (i = 0; i < 100000; i++) { x = p["testme"]; } 1242.8 75.56 1645
x = null; p = new Person(); for (i = 0; i < 100000; i++) { p["name"] = "test"; } 1322.8 82.2 1609
for (i = 0; i <= 100000; i++) { i.ToString(null); } 3257.8 773.06 421.4

As you can see the performance improvements for loops, method calls and array manipulations range from 200% for 3000% and this is not the complete list.

Here’s the graphical charts for the first 50 calls of each script benchmark (vertical axis is given in milliseconds):

image

image

image

image

image

image

image

image

All the tests were performed on Windows 7 Ultimate ( x64), Intel Core 2 Duo T9400, 2.5GHz, 4GB RAM

Dynamics

I’m glad to announce that S# 2.0 will support “dynamic” objects powered by .NET 4.0 and its DLR (Dynamic Language Runtime) part. There will be a new type alias called “dynamic” that will allow you creating objects on the fly similar to the following sample:

person = new dynamic();
person.Name = “John Doe”;
person.Age = 40;

This should significantly improve scripting experience an reduce efforts required to perform complex reporting or visualization scripts as types can be created dynamically during script execution instead of creating custom types and registering them within the runtime host.

The performance of dynamic objects is also very important for us. For the moment object property access (both getting and setting property value) is much quicker than of plain CLR type:

image

 

Integration

You will get more samples related to S# integration with other technologies and products. Soon there will be a set of articles regarding new features in S# for WPF and Silverlight, Microsoft Office 2007/2010 etc.

S# framework will provide a new libraries targeting OpenXml SDK 2.0 reuse within the scripts. It will be possible getting and setting data for Microsoft Excel 2010 document by accessing cells in scripts similar to the following way:

workbook = new Workbook(“Book1.xslx”);
workbook.Sheet1.A1 = “Hello world”;
workbook.Sheet1.A2 = 100;
workbook.Sheet1.B1 = workbook.Sheet1.A2 + 200;

More news are on the way…

Advertisements