Managed meets functional

Blog about programming and having fun with .Net

About me

 Venice, 2009

profile for Alexander Galkin on Stack Exchange, a network of free, community-driven Q&A sites

Project Euler

Greetings here in my blog!
My name is Alexander Galkin. I was born 1979 in Kazan, Russia, where I graduated in child medicine.
Since 2001 I live in Hamburg, Germany and work as a freelancer software and database architect and trainer for Microsoft technologies.

 Microsoft Certified Trainer
Microsoft Certified Professional Developer
MCTS Logo
MCITP Logo

Calendar

<<  May 2013  >>
MoTuWeThFrSaSu
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

View posts in large calendar

Sample scenarios for Azure

Some potential scenarios for Windows Azure different services, from my answer on StackOverflow:

Azure Mobile Services cover the scenarios where you have multiple (mobile) devices running occasionally connected applications that need to synchronize their content through the cloud. AMS provides you with the possibility to implement the custom processing logic for data requests and updates; it hides the burden of implementing and hosting a web service. About 90% of the logic is set or written directly in the management portal, the rest is just the client logic. The main purpose of this service is data sync (this is the core functionality), all other services (authentication, logging, scheduler) are just auxiliary. The language used for development is JavaScript, the whole development is similar to server-side development using frameworks like Node.js.

Azure Web Sites is the way to host your code within IIS, that usually would be a web page, but nothing hinders you on hosting your web services (Web API based or even full-fledged WCF) here as well. Azure Web Sites are easy to deploy and this is a rather cheap solution for hosting web services, provided you allow other IIS applications (from other users) to run here as well (shared instance), but you can also prioritize your application by going for a reserved IIS instance (and pay more). Sure, you can reuse most (virtually all) of your existing business logic here (unless you need something exotic like interop or shell access that can't be hosted in IIS natively). The disadvantage of this solution is that your logic will run within the context of your web service and for long running processing this might be a non-optimal solution.

Azure Cloud Services allow you to defer the processing of logic rules and to decouple the logic from the service input. In this scenario you can have two kinds of roles, typically called web role and worker role. Web role provides endpoints for your services and queues the requests, the worker roles reads the queue and does processing. This allows you to fine tune your load balancing and capacity planning, increasing the number of parallel instances with web roles and worker roles.


Categories: Azure
Permalink | Comments (0) | Post RSSRSS comment feed

Sample databases for SQL Azure that support Entity Framework

While working on my tutorials for SQL Azure as backend for LightSwitch I bumped into the problem that the SQL Azure sample database AdventureWorks is not (fully) supported by the latest version of Entity Framework (EF5). This has the consequence that one cannot create the Data Context for the whole database that would be a prerequisite for all frameworks using EF for data access (besides LightSwitch, ASP.NET Dynamic Data application would be also impacted).

In my case I only needed a demo database, so I just found the old good Nordwind database for SQL2000, installed it locally and migrated to SQL Azure instance. Then I could easily create the Data Context in EF5 and implement sample applications in LightSwitch.

So, summing up my experience, as long as you need a sample database running on Azure, you might

  1. Take the SQL Azure version of AdventureWorks here, you might need to exclude some tables from Database Model, however, to get this database working under Entity Framwork 5.
  2. You can use the "old good" Nordwind, download a legacy version for SQL2000 from MS page and migrate it towards SQL Azure.
  3. Use some other sample database, like Chinook and use them. Chinook provides full support for EF5, or, in other words, EF5 supports everything Chinook implements.

Permalink | Comments (0) | Post RSSRSS comment feed

iTunes suddenly fails to start on Windows 8

Yesterday I faced the unexpected problem that my iTunes stopped working. Just three weeks ago it was all fine and I could start it without any problem, and now it does not start at all. Whenever I start it from the start screen, it pops up in the list of processes for about 10-15 seconds and then exits, starting no GUI thread whatsoever.

The solutions that are suggested in numerous support forums are usually to start it in the compatibility mode. This is wrong, please don't do it, because iTunes detects that it has been started in the compatibility mode and might refuse to work because of it!

The correct solution is to uninstall Quicktime. It works like a charm and you don't even have to restart your computer afterwards. Just make sure that you choose to "Uninstall completely" (the leftmost option in uninstaller).

Interestingly enough, the Solution Finder tools from Windows 8 also suggests the compatibility mode, and even that of Windows XP. Please, don't follow this recommendation.


Permalink | Comments (0) | Post RSSRSS comment feed

Approaching Fletchers as if they were Software Developers

I had to write a sample job offer for my English class and decided to approach this task with creativity, so I came up with a job offer for a fletcher instead. Enjoy! 

Senior Fletcher

BowMasters (www.BowMasters.com) is a leading bow manufacturing company. BowMasters offers consulting, bow development and maintenance, BRP and BPO services to the clients across the globe. With its relentless focus on achieving the highest quality in its deliveries, BowMasters has become a trusted brand and achieved consistent growth in its repeat business with its clients.

BowMasters is renowned for its experience in working with the world's best technology companies and some of the world's leading enterprises in the vertical industries. Our commitment to quality is reflected in the fact that all of the world's top five technology companies are currently long-term clients of BowMasters.

BowMasters's is looking for a world-class fletcher who will do design, manufacturing, testing and maintenance of fletching for customers worldwide. 

Our team consists of highly-skilled bowyers, fletchers, and arrow head makers, who are passionate about building the internationalization infrastructure that enables our products to be used by millions of users worldwide. 

Job qualifications:

• The candidate must have a M.Arch. (Master of Archery) degree

• A minimum of 4+ years related manufacturing experience with outstanding track records.

• Expertise in fletching for long- and flatbows, composite and compound bows.

• Knowledge of recurve and laminated bows is a plus.

• Strong skills in bodkin, judo and target points, as well as field points and blunts. 

• Good understanding of military, mounted and field archery;

• Good knowledge of bow strings;

 

Responsibilities:

• Manufacture fletching for new bow models;

• Maintain existing bow models, manage social contacts with customers and control user experience;

• Document activities from design to completion and participate in testing of projects;

 

Location: San Francisco, CA

Compensation: DOE (up to 100k), competitive salary and equity, flexible work hours, stock options, matching 401(k) contribution program, comprehensive health benefits (medical, dental, vision), free lunches and snack, semi-annual bonuses based on company performance, monthly commute allowance

Principals only. No relocation provided.

If you are an extraordinary person who strives for excellence, please submit your resume via pigeon post, pigeon hole #114. BowMasters is proud to be an equal opportunity employer that is committed to a diverse workforce.

 

 


Categories: general | opinion
Permalink | Comments (0) | Post RSSRSS comment feed

Expression Blend crashes on start-up with error in the .NET Runtime at IP 5F791825 (5F790000) with exit code 80131506

There is an incompatibility issue between Expression Blend 4 and .Net 4.5 (currently as a developer preview installed as a part of Visual Studio 11 Preview). 

This issue leads to Expression Blend crash on start-up with the following error message: "The process was terminated due to an internal error in the .NET Runtime at IP 5F791825 (5F790000) with exit code 80131506."

The issue is reported on MS Connect and there is a workaround: download the attached bat-file, store it to a temporal location, right-click on the file and select "Run as Administrator" from the context menu. This solved the problem in my case.

blend.bat (576 bytes)


Permalink | Comments (0) | Post RSSRSS comment feed

Updated version of GLSL parser by Laurent Le Brun to compile with FParsec 0.9.1

GLSL parser by Laurent Le Brun is a gold nugget for those who would like to use FParsec to parse C-like languages. As I have plans to use this script as a starting point for my TouchDevelop parser, this script was the first I looked at after I fixed F# support in my Visual Studio 2010. 

It turned out, however, that the script is somewhat outdated: written in 2010 (according to the date of the blog entry) it requires an earlier version of FParsec library. Trying to compile it against the latest stable version of FParsec (0.9.1) fails due to some deprecated names (mostly abbreviations that were previously used in FParsec, like "Assoc", are now written in full). Besides, the syntax for SyntaxParser generic constructor has been changed to include the UserState type. 

I adapted the code by Laurent Le Brun, the working versions of the script with minimal changes (see below) can be downloaded from this blog entry.

Changes compared to the original version of the script:

  1. Assoc -> Associativity
  2. µOp -> µOperator where µ in {Infix, Prefix, Postfix, Ternary}
  3. Parse -> GlslParser
  4. Ast -> GlslAst
I also put together a small VS2010 project containing the latest version of FParsec along with a sample GLSL script that is automatically parsed if run in debug mode.
Files:

glsl_parser.fs (8 Kb) 

VisualStudio 2010 solution with FParsec 0.9.1 and sample script (1.36 Mb)


Categories: .net | F# | parser
Permalink | Comments (0) | Post RSSRSS comment feed

Using LINQPad as scrapbook for FParsec

FPrasec is a smart implementation of the famous Parsec library from Haskell. 

FParsec belongs to the class of parser combinators, meaning that you don't have any IDE or formal definition of your grammar (as in case of ANTLR/ANTLRWorks). Rather you deal with some primitive parsers which can consume strings, digits and combine them in a clever way to implement your parser. The main advantage here is that you have the full control over what you are designing and can use the full strength of the underlying language (in this case that of F#).

Since I have got problems with F# in my main Visual Studio installation which I couldn't not repair (here is the respective StackOverflow question) I decided to use my favorite tool LINQPad for learning and designing parsers and it worked perfectly.

So, if you want to use LINQPad with FParasec the only thing you have to do is to add the references to FParsec DLL. This is done by going to the application menu:

and then add both FParsec.dll and FparsecCS.dll to the "additional references". You will find these DLLs after the first compilation of the FParsec source code. 

For your convinience I am attaching an achive with pre-compiled DLLs to this post.

From now on you can use FParsec freely, just don't forget to open the FParsec namespace in your code.

I also adapted the examples from the FParsec tutorial to run in LINQPad. Those samples expect the DLLs to be stored under the follownig path: D:\Dev\FParsec\DLL\

You can download the complete tutorial scripts and the samples provided with the FParsec using the link below.

FParsec.dll and FParsecCS.dll (.zip, 176 kb) 

LINQ queries for tutorial and samples (.zip, 13 kb)


Categories: F# | parser
Permalink | Comments (0) | Post RSSRSS comment feed

About Refactoring

I just answered one question on Programmers@SO and would like to post my answer here as well:

Q:

  1. How does [refactoring] takes place in the Software development process and how far it effects the system?
  2. Does Refactoring using these tools really speed up the process of development/maintenance?

A: First of all, depending upon the site of refactoring one can distinguish several types of it: code refactoring, database (schema) refactoring, refactoring of unit tests, refactoring of GUI etc.

There are several situations where you can meet refactoring during software development:

  1. Refactoring is known to be a mandatory step in certain agile development techniques like test-driven development. It is supposed to perform refactoring step after every implementation step. In this case the refactoring targets just the last implementation and its goal is to integrate the new code into the existing code corpus in the most optimal way.

  2. Refactoring can be done some internal problems in the working code are detected: this is called "code smell". This estimation is in many aspects rather subjective, despite the fact that it can be actually based upon certain code metrics (like number of lines of code per method, cyclomatic complexity of the code etc.). Here the goal of refactoring is to improve the code quality by changing it so that the metrics used for quality estimation return to the expected domain.

  3. You often need to refactor the code to achieve certain principles of programming in your code, look for Clean Code development to learn more about such principles.

  4. You may need to perform refactoring of your code and database schema to prepare it for coming changes, especially if those were not considered during the design phase of the project. For example data normalization and denormalization take often place during data-driven software development to prepare the database for possible extensions.

Refactoring tools available on the market basically support the developer in two ways:

  1. While writing your code, you get suggestions how you can improve it "on-the-fly". Whereas many fallacies can be detected directly by your IDE, like Visual Studio or Eclipse (for example dead code, variables declared but not used etc.), the refactoring tools like Resharper can reveal problems which are far less evident, like re-writing the loops in LINQ queries etc.

  2. These tools also support you with custom refactoring steps, like global renaming of your identifiers, splitting your class declarations into separate properly named files, extracting interfaces and base classes from your class implementation etc. They save a lot of work here, especially if your project has a large code base, but you must first know what you really want to refactor.

Actually using tools like ReSharper in everyday's development is so useful that it makes you almost dependent on them: they really accelerate the process of code writing, especially if you know how to use them appropriately!


Permalink | Comments (0) | Post RSSRSS comment feed

Class diagram for CodeDom namespace in .Net

CodeDom namespace in .Net is one of several ways to develop your own compiler or source code generator in .Net. Even somewhat abandoned, it currently support for following languages:

  • C# (native, out-of-the-box),
  • VB.NET (native, out-of-the-box)
  • F# (native, out-of-the-box)
  • IronPython

CodDom provides you with the classes to build your own abstract syntax tree of your code, which can be either compiled to "binary" aka CIL or translated "back" to a high-order general purpose language from the list above. This explains why it is rather a complex namespace with many classes and non-trivial class hierarchy. If you try to build class diagram for this namespace you come up with the following image:

Since it is absolutely impossible to work with diagram I prepared a set of diagrams covering large constellations of classes.

So, here you have:

  1. A general overview of CodeDom namespace classes with "pruned" tree.

  2. Collections and enums.

  3. CodeStatement

  4. CodeType

  5. CodeExpression

     

So, feel free to use these diagrams in your work. There is no explicit license attached to these images (I haven't drawn them, just used the VS2010 designer), so in case of a question just consider my work being a public domain.


Permalink | Comments (0) | Post RSSRSS comment feed

How To: Improve the performance of Visual Studio UML and class diagramm designers

If you feel that Visual Studio 2010 UML or class diagramm editor became slow and not as responsive as it is used to me, especially if you are working with many objects at a time, then you should try to close the property window. Strangely enough this window gets populated every time you select an object and in case if you select many objects it shows only the commonly set properties. This is the reason why the editor becomes so slowly (even though iit does not explain why it takes so long to populate the properties window).


Categories: how-to
Permalink | Comments (0) | Post RSSRSS comment feed

A wonderful collection of bit hacks, interesting for every programmer

Have you ever tried to count bits in a bit-array structure without using shitfts? Or probably used bitwise XOR for a primitive but effective cryptography? Then you will definitely like the following webpage, providing an absolutely wonderful collection of non-trivial bit manipulations for achieving marvelous results. Really a great place to read and to take away some pieces of bit manipulation magic.

 


Permalink | Comments (0) | Post RSSRSS comment feed

Object-Relational Mapping: a handy design pattern or a spoiling anti-pattern?

Today somebody asked the question about the nature of ORM in development: should we consider it a useful pattern or an anti-pattern.

Here are my thoughts on the topic (just copy and pasted from StackOverflow):

Actually ORM helps you to quickly implement a data-base connectivity and implement your application logic without paying much attention to the actual connection to database. You are allowed to use the entities of your programming language while implementing the logic and you don't have to care about how these are then translated into the relational model of database. This is the main advantage for me and that is why ORM is so popular -- you can develop a simple data-driven application in just a couple of hours.

So, ORM, as many other technologies like managed code, garbage collection, generics etc. is optimized for developer productivity, e.g. to minimize the number of developer hours (that are normally quite expensive) needed to implement certain functionality.

As long as you have other criteria that may override the above mentioned one, like performance, application size, flexibility of the logic, network throughput, code size (both of the source and compiled) ORM is not your friend anymore. But since this is not a common scenario people usually don't care and take ORM for their applications.


Tags: ,
Permalink | Comments (0) | Post RSSRSS comment feed

Why C++ is not good as the first programming language

This term I teach the course "Introduction into Programming with C++" for the first-year students of Engineering Sciences. 

The course was requested by the University and targets the students with no prior knowledge of programming. The choice of C++ as the language of the course was not mine, this is the default language to teach OOP at our university (Hamburg University of Technology), for the professor in charge is doing his research primarily using C++. So, the decision to use C++ as the first language was more or less imposed on me by the dean office.

During the very first session I provided students with several motivating examples. One of those was the classical task about the chessboard and the wheat beads, where  one Vizir truly enchanted by the wonderful game of chess asks the inventor for a decent reward and the latter asks him to put one wheat bead on the first field, two beads on the second fields etc. until every field is covered. This seemingly trivial task results in a very high number which is not so easy to compute directly using a brute force approach (without deriving the summation formula for this geometric row).

So, we implemented this task in several languages. Here is the one-line implementation in F# (MS version of oCaml for .Net):

let rice = 
     [0 .. 63] |> List.map (fun x -> 2I ** x)  |> List.sum |> Dump

The equivalent C# (and with small changes C++) code is much longer and requires much more things to keep an eye on:

void Main()
{
	ulong sum = 0;
	for(int i = 0;i < 64; i++) 
	{
	  sum+= power2(i);
	  sum.Dump();
	}
	sum.Dump();
}

// Define other methods and classes here
ulong power2(int power)
{
   ulong answer = 1;
   for(int i=0; i < power; i++) answer=answer * 2L;
   return answer;
}

This is why I do agree with the widely spread opinion that Computer Science and especially the algorithms should be first taught using a non-imperative language, like Haskell, oCaml, Erlang, Scala or F#.


Permalink | Comments (0) | Post RSSRSS comment feed

I will be at TechEd 2010 Europe in Berlin

Hi, everyone!

It has been quite some time since I wrote something in my blog, mostly because I was busy with my studies.

But today's news could not evade my blog: I will be attending TechEd 2010 in Berlin this year.

I will be working there as an invited MS Expert at Silverlight Booth.

So, if you happen to be there as well, come to our booth!


Categories: general
Permalink | Comments (0) | Post RSSRSS comment feed

The Zen of live coding: Win7 Zoom feature and ZoomIt from Sysinternals!

If you have ever presented something to the developer audience you have definitely had to show some features or code samples live. I often combine live coding with slide presentations, not only because it makes people wake up, but also because it gives your presentation a professional and lively touch, helping you to win the audience in case if the topic does not seem to be extremely interesting to the majority of them.

During these live shows I often feel the need to zoom to certain area of my screen in order to emphasize the actions I am taking or the code menu items I choose. The easiest way to achieve it if you present on a foreign laptop is to use the new Win7 zoom feature. By holding Winkey (the key located between Ctrl and Alt on the left-hand side of keyboard) and pressing "+" and "-" on the additional keyboard (known as "Grey Plus" and "Grey Minus") you can zoom in and out respectively.

There are several zoom levels you can reach if you press these buttons several times, enabling you to focus on the tiny little part of your screen. Your system remains fully responsive during and after zoom, you can just continue typing or choosing menu item, the magnifier would normally follow the mouse cursor (this feature is called "live zoom") unless explicitly set otherwise. If you want to leave the zoom modus you have to left-click on the magnifying glass and close the magnifier panel.

This built-in option equips you with a very handy presentation tool working right out-of-the-box. However, you might sometimes need a little bit more than just zooming. During my live presentations I often have the situation where I need to freeze the screen content for a while and to explain something in more details. I was desperately looking for a free solution which would assist me here and found a very nice tool from Systeinternals webpage called ZoomIt.

This is a small single executable (about 500 Kb) which has to be started manually and which resides in your tray after start watching for the keystrokes. The default key-mappings (Ctrl + 1..4) collide with keyboard layout switch in my system that is why I changed those, in your case you may wish to do the same, you just have to right-click on the magnifying glass icon in the tray and choose "Options":

As you can already guess the from context menu, there are basically three different functions you can run by pressing keystrokes or from this context menu.

  1. Zoom

    Zoom works similarly to the Win7 zoom feature, except for the fact that there is no more mouse pointer visible; the screen zoom, however, follows your mouse movements until the first mouse click, which unveils the reason for such a strange behavior. Basically, zoom mode captures the screenshot of your desktop and you zoom to the still non-interactive image. Being in this modus you have two options: by clicking the right mouse button you fall back to the normal screen and can continue working, by clicking the left mouse button you enter the drawing mode and can now draw with your mouse pointer, depicted as a small cross.

    By clicking the right mouse button you can go one step back and continue to zoom throughout the screenshot of your desktop. You can go back to the normal working mode either by clicking right mouse button twice or just by pressing Esc in the draw zoom mode. There are multiple keystrokes you can use in the drawing mode; you get the full description if you go to the "Draw" tab of the "Options"-Form.

    Strangely enough, there is however one keystroke which is missing in this very detailed description (you'll however find this keystroke on the adjacent tab). If you press "t" in the drawing mode you can enter any text (it will be printed using the color of you pen) and finish the text entry by pressing Esc. This helps you to annotate the screenshots quickly.

     

  2. Draw

    Draw mode is practically the same we were describing just above, the only difference is that you don't need to zoom first and you the screenshot of your complete desktop as a template for your artistic exercises.

  3. Timer

    This is a nice option if you deliver talk or workshop where you have some assignments (like implementing "Hello, World!"). In order to dim down your presentation or IDE and to stress the importance of the exercise you can start the stop clock which would countdown the time (default for 10 minutes) until the deadline.

  4. LiveZoom

    Working only on the systems starting from Vista on this mode completely mimics the zoom feature of Win7, e.g. you have a completely functional desktop you zoom at and you can continue working (typing) whereas the part of your desktop is shown magnified. Even though it may be also handy to use it as alternative to the built-in feature, I feel myself often trapped while using this feature because it is not evident how to live this mode (since the Escape button does not help you). Just press the keystroke once more to go back.

In conclusion I can just recommend you to have ZoomIt on your memory stick together with your PowerPoint presentation, so you can start this handy tool every time you need to present something (there is no need for elevated privileges to start it). With some practice you will be able to produce rather complex annotations to your desktop using this tool only!


Categories: english | sysinternals
Permalink | Comments (0) | Post RSSRSS comment feed

How to disable password request on logon in Windows 2000 – Windows7?

Password protection is essential part of the security policy and you should consider disabling it as the uttermost measure. The possible scenario includes home machine with no domain identification used only at home by family members. Do not disable the password request on your laptop under any circumstances, you may probably want to configure your laptop not to re-request your password on wake-up, but it is essential for keeping your private data secured against undesired access in case of laptop being lost or stolen.

So, in order to disable logon password request you have to do the following:

  1. Download the Autologon utility from sysinternals collection from here:
    http://technet.microsoft.com/de-de/sysinternals/bb963905.aspx
  2. Start the tool with elevated privileges:
  3. Confirm the start with elevated privileges (using safe desktop if you have UAC activated on Vista/Win7).
  4. Accept the license agreement.
  5. Enter your computer name for logon as a local user or domain name for domain logon.
    Then enter your username (local or domain) and password (shown as asterisks).
  6. Click "Enable" to enable autologon.

From now on your system will logon automatically.

In order to disable autologon in the future you have to either change the password of your account or re-start the tool and click "Disable". A message window will prompt the new status of autologon (enabled or disabled).

This solution was tested on Windows XP Professional and Windows 7 Ultimate, reportedly it also works for Windows 2000.


Categories: sysinternals | english
Permalink | Comments (0) | Post RSSRSS comment feed

Technorati relauchned! How to make you blog discoverable.

After reviving my blog with the sysinternal entry I went to Google Analytics to check what kind of users visit this blog. To my surprise there are more people looking for my German CV than any from the IT-area. That made me think it would be nice to get my blog registered somewhere like Technorati in order to get some more target group visitors.

Since relaunch of Technorati there is no more need to add Technorati tags to your every post, the site implemented the architecture known in the IT-world as "inversion of control", meaning that rather than submitting your posts with certain tags you just post normally and the system tries to discover your blog posts and to put them into respective category.

In order to make you blog "discoverable" you have to sign up (or sign in, depending upon your current status at Technorati) and claim your own blog. After filling up all necessary fields as to the URL and feed URL you are requested to put a code (PBFE7PQ3VWN9) provided by the page into the most recent blog entry in order to prove you are the owner of the blog and verify your blog.

As soon as Technorati crawler verifies the token your blog is scheduled for review which may take some time.


Permalink | Comments (0) | Post RSSRSS comment feed

How to measure the execution time of your program in Windows?

There are often cases that you need to measure the execution time of your program. Working in Windows or Linux one gets used to the "time" system utility, which allows one to measure both system and kernel time of any executable just by preceding it with complete parameter set in the command line (for instance "time du").

Pity, there is no such a handy routine in (usual) Windows installation and the "timeit.exe" solution which one might find on many Internet forums does not seem to work in all cases (at least it does not in my case of Windows 7 Ultimate). There is, however, a nice workaround for this problem, provided you want to measure the execution time of one or few runs, by using Process Explorer from Sysinternals toolset by Mark Russinovich. This solution, however, does not help in case you need to perform multiple performance run tests of your software. Please, refer to Visual Studio Profiler in this case.

  1. So, first you need to download the latest version of Process Explorer from here:
    http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx
       
  2. Once you downloaded it and agreed to the user agreement you can see the main screen:

  3. You first should add the parameters you'd like to get from your program to the list of visible columns. For this purpose go to View and choose Select Columns

  4. Go to the "Process Performance" tab



    and select the counters you'd like to see in the general process list. In order to get the total execution time you'll need to tick the "CPU Time" option:



    Click OK to go back to the main screen and you will see the new column CPU Time to the very right of the process table. The order of columns can be easily changed just clicking on the column caption and dragging it to the desired position.

    Note: You might need to enlarge your Process Explorer window to see the new column.
  5. Now you are almost ready to capture the information you need. However if you now start your process and immediately switch back to the Process Explorer, find it in the list of running processes and wait until it terminates you can read the total execution time in the CPU Time column. It works fine in many cases, but you may encounter two types of problems:
    1. If the process you start just runs shortly you may miss your process, for it is already finished by the time you have switched back to Process Explorer and found it in the list.
    2. Even if you managed to get your process, the information about total runtime is quickly purged from the process list.
  6. To solve these problems let us increase the time process is shown in the list after it has terminated. For this purpose go to Options -> Difference Highlight Duration and set the duration to 9 seconds:



    Now the process will remain in the list for 9 seconds after its termination.



    That should be enough to write down its execution time. Now just start your program and read the execution time after its termination. You can easily identify the process which terminated shortly by the red background highlighting (on the screenshot you can see the "pan.exe", the compiled verifier from Spin).


Categories: general | sysinternals
Permalink | Comments (0) | Post RSSRSS comment feed

Office Palmistry and SELECT DISTINCT

Das wahre Office

Microsoft Academic Programm plans as a part of its activity to support the "Das wahre Office" ("The authentic office", search for "Ultimate Steal" in Internet for a similar campaign in Ireland; just in a nutshell -- undergraduate students can obtain the MS Office 2007 Ultimate for the price of barely €50) campaign to arrange several lectures and workshops throughout Germany under the tagline "Office Themen-Tagen" ("Thematical Days of Office"). As a big and longlife fan of MS Office (starting from as early as its version for DOS!) I am going to deliver several lectures on applied office topics. It is planned that I mostly concentrate on MS Word, MS Excel and MS Access whereas other Microsoft Student Partners will cover the rest of the Office 2007 Ultimate Edition except for the products with dubious end-user value (like InfoPath, for example).

Office Palmistry, Taming the Word

This campaign just prodded me to produce several video tutorials for these MS products and probably to devote some more time to Office. So, just to contradict the Shakespeare's "a rose by any other name would smell as sweet" I came up with a provocative and edgy title for the whole series of videos -- "Office Palmistry" -- and for its first part, officially known as "Scientific Writing with Word 2007", but published under its running title "Taming the Word". Here you can read the script of the first video.

I haven't decided yet where I would like to host these videos and so far I am just learning how to produce videos under Vista. Meanwhile the script of the very first tutorial is ready and meanwhile I publish it here in my blog. I will probably move it somewhere else in the future (do you have any suggestions), especially as I have the screencast for it ready.

SELECT DISTINCT with several columns

As regards the pivotal topic of this blog -- I am currently working on a rather big tutorial on preudo-SQL SELECT DISTINCT (col1, col2, col3), col4, col5 FROM Table1 command and how to write querries which would do that is meant by such a crippled SQL query. I will try to publish it this week (since this is the only week I have off in the University).


Permalink | Comments (0) | Post RSSRSS comment feed

Sets and set operations in .Net or "Why do we reinvent the wheel?"

Resurrection of Delphi

As a dilligent subscriber of DotnetPro-Magazine (monthly developer magazine in German) I read in the last issue about the reincarnation of Delphi and Object Pascal undet the .Net platform. Before .Net Delphi was the language I had had most experience with, spending days and weeks trying to develop my own visual components and to develop something worth to show the others. Delphi is still the IDE of choice if you need to programm something, which should be compiled into the native code and should run on a variety of Windows Systems, starting from Win98SE on. In my last project where I had to programm the software which controls acoustic modem in marine research I had to use it again (in 2009, imagine!) in order to make sure that the final code will run on both old and new laptops they have.

Sets in .Net and C#

One of the articles of the actual issue was about "mimicking Object Pascal sets under .Net" by Bernd Klaiber, where he describes the class, developed by him in order to get a behaviour similar to what is called "sets" in Delphi. I was a little bit surprised to read about this implementation and even recommendation to use this "generic implementation with overloaded operators" implementation, which is somehow compared to the classical C# Flags. This is, a propos, the only point I agree -- the implemenation offers much more functionality compared to Flags, but do we really need this functionality?

Classical implementation from 2002

First of all there is a classical and well-known implementation of sets under .Net, which can be found and downloaded from CodePage. The implementation (and the article in the CodePage portal which supports it) was published as early as in 2002 and was revised in 2004, it implements a whole hierarchy of Set classes, implementing not only the classical set, but also dictionary and hash sets. The implementation does not overload any operators, probably because it was mainly implemented before this became possible in .Net (even though it is implemented as a generic class in the latest version available on CodeProject).

Drawbacks and what we actually need

I used this implementation in one of my projects at work and found it not so handy, because you have to deploy 2 separate DLLs together with your code (this is just one stand-alone DLL), even if you use just the smallest part of the overall functionality. By the way, when I think of sets, I basically think of the following features: ability to have a set of data where I can add to and remove from and check whether a certain element belongs to the set of not. Other operations like union or interseption are nice, but if I need them I rather use something in the direction of SQL-server or SQL-provider to implement this feature. That's why basically speaking of sets we need three operations:

  • Add something to set.
  • Remove something from the set.
  • Check, if something belongs to the set or not.

Flags

For static values one should take the classical C# flags, which are nothing more than a binary enum with possibility to check for certain bit. Here is just a small extract from my C# workshop demo project to illustrate the issue:


[Flags]
enum DaysOfWeek : byte
   { Monday = 1, Tuesday = 2, Wednesday = 4, Thursday = 8,
         Friday = 16, Saturday = 32, Sunday = 64 }

public static void FlagsTest()
{
   DaysOfWeek workingDays = DaysOfWeek.Monday | DaysOfWeek.Tuesday
                 | DaysOfWeek.Thursday | DaysOfWeek.Wednesday | DaysOfWeek.Friday;
   DaysOfWeek today = DaysOfWeek.Monday; 
   DaysOfWeek day1 = today;
   day1 |= DaysOfWeek.Sunday; // adding new day
   day1 |= DaysOfWeek.Tuesday; // adding another day
   day1 &= ~DaysOfWeek.Saturday; // removing one day
   if ((today & workingDays) != 0)
     { Console.WriteLine("Today is " + today + ", working day"); }
   else
     { Console.WriteLine("Today is " + today + ", holiday"); }
 }

What if we need more?

To some reason unknown to me there are quite a few who know that there is actually a full-fledged set class in .Net starting from the version 3.5. This is the hashset class, which implements all methods we need in order to manipulate elements and check for them. It supports .Add(), .Remove() (together with .Clear()) and .Contains(), the basic 3 operations I ever needed from a set. Besides, it also supports many real set operators like .ExceptWith() or .Overlaps(), which were so arduously implemented in the article.

Then I switched to this class in a newer implementation of my project at work the total project sized schrinked from about 800Kb down to 16Kb (imagine!) and I didn't have to deploy two separate DLLs with my project anymore (that was great!). The only method which I missed a lot was the .AddAll(T[] T) methods, which woud allow me to add the whole array of elements to the set at once, without implementing a loop. That's why I just briefly concocted the following class:


    class SetOfStrings : HashSet <string>
    {
        public bool AddAll(string[] newItems)
        {
            try
            {
                foreach (string newitem in newItems)
                {
                    base.Add(newitem);
                }

            }
            catch (Exception)
            {
                return false
            }
            return true;

        }
    }

Alas, this new class was not generic anymore (I did not care for it because I my set was hard typed), but it implemented the functionality I needed. Apparently it was the only difference between the CodeProject class and the hashset, since the rest of the code just worked without further correction. Now I use this code in several project I work at and I am fully satisfied with the execution speed and flexibility.


Permalink | Comments (0) | Post RSSRSS comment feed