Optimizing existing code for performance is one of my favorit tasks. It is a work what gives immediate measurable feedback, always learns you something new, and is in many cases easier then you think, especially if you use the new profiler in vs2010.
Setup
The first thing you need to do is find some way to test that you still deliver the same functionality. Now days this tends to be less of a problem, as many projects tends to have some kind of unit tests (although in many cases it’s more automated Integration tests) . If not it time to write some
Other ways to accomplish this is to agree/ write some testcases
Establish a base line
Once you have a way to test that you don’t (unknowingly) change the functionality its time to find and reproduce the performance issues. It is not reproducible in a new environment, it's in most cases better to try to find the bottlenecks in the environment before you go for optimizing the code.
After reproducing the performance issues, the next step is to establish a base line. By setting a baseline before you start changing the code you have something to compare your results against. Establishing a baseline is more a procedure and some extra thoughts on how to test and measure your progress. In practical it’s the first performance report you collect from your system saved away
Creating a performance session
Now its time to get started, simply create a new performance session, As before you can choose between sampling and instrumentation.Sampling providing a quick and good enough approach and instrumenting as an more exact and complex approach. I tend to end up doing the instrumenting, although I must admit sampling really is good enough for me, I guess I like the feeling of exactly knowing what’s going on. You can read at msdn: Walkthrough: Profiling Applications
All in one profiling
A new feature in the Vs2010 profiler is that it now collects data about calls to other tires like the database. Before I was most of the time forced to use both the Profiler and SQL server profiler to collect information about database interactions and where execution times. With VS2010 I now can collect basic database interaction information directly in the VS2010 profiler, showing you the queries executed and their execution time. This information is valuable enough to point me in the right direction witch query to look deeper into, although I still can see cases there I will use the SQL Server Profiler.
Better performance reports
One other great improvement from usability perspective is the new graphical presentation of your function, both showing a graphical representation of the time spent in the function, and the code annotated with execution times! The graphical representation of the function calls is also clickable. This makes it really simple and almost joyful to navigate around in your callstack looking at the code and the execution times, giving you a quick idea about what needs and can be improved.
Colin Thomsen has writen 2 post about the new performance reports VS2010: New Profiler Summary Page and VS2010: Investigating a sample profiling report (Function Details)
Wednesday, January 20, 2010
Tuesday, December 8, 2009
A new beginign for the TFS AdminTool
If I had to pick the most important tool for TFS, it would without a doubt be the TFS Admin tool. It has saved me (and many others) a lot of trouble and many, many hours. To be truly honest it has made me say some bad words to, from time to time.
This makes it extra joyful to read Ladislau’s post on the release of a CTP for the new TFS Admin 2.0 version with TFS2010 Beta2 support.
New user interface
The CTP shows of a completely new user interface. New Features includes
• bulk edit of users
• pending changes window
• output/trace window.
The most important is that the new UI seems to be more reliable than the old one.
Completely redesigned and rewritten codebase
The new user interface is not the only thing the team behind the TFS admin tool has accomplished. The TFS Admin code has gone through a major reconstruction, separating the user interface from the logic and making the code more testable. The core management of user rights is package in a separate project/assembly making it very easy to use/and extend. It is now possible to write your own gui/process and relay on the TFS admin tool to take care of the boring and time consuming tasks. Great news for the TFS community!
This makes it extra joyful to read Ladislau’s post on the release of a CTP for the new TFS Admin 2.0 version with TFS2010 Beta2 support.
New user interface
The CTP shows of a completely new user interface. New Features includes
• bulk edit of users
• pending changes window
• output/trace window.
The most important is that the new UI seems to be more reliable than the old one.
Completely redesigned and rewritten codebase
The new user interface is not the only thing the team behind the TFS admin tool has accomplished. The TFS Admin code has gone through a major reconstruction, separating the user interface from the logic and making the code more testable. The core management of user rights is package in a separate project/assembly making it very easy to use/and extend. It is now possible to write your own gui/process and relay on the TFS admin tool to take care of the boring and time consuming tasks. Great news for the TFS community!
Thursday, October 15, 2009
VSTS2010 as a modeling tool II
In my last post I wrote about VSTS 2010 as a modeling tool for more abstract levels like general UML illustrations and requirements modeling. In this post I will take a look at VSTS2010 as a modeling tool for more technical modeling.
UML at the concrete level
The next step after requirements is usually to do some kind of analyzing and/or basic design as the first step towards the destination - real code. After the initial design the next step is to complete the design into a fully technical specification. Now days many projects tend to skip formal analyzing and initial design and go direct to coding. For the people who do go all the way there is/has been tools like Rational Rose/XDE, Enterprise Architect and UModel who could even go the whole way to generate code from the design.
VSTS2010 as an analyzing and initial design tool
Doing analyzing and initial design requires more of your tool than just fancy images. You need some kind of repository to share and reuse your discovered elements. VSTS2010 handles this through the UML Model Explorer. The model explorer act as an in memory repository making it possible to browse through your defined elements. You can organize your elements hierarchy in the model explorer by creating package.
In VSTS2010 you can create class, activity and sequence diagrams and drag and drop elements from the model explorer to your diagrams. Changing objects, like renaming classes or operations, updates all diagrams. It is also possible to promote object and messages to classes and operations. Basically it got most of the capabilities needed for analyzing and initial design of a system.
VSTS2010 as an advanced design first tool
When it comes to doing model first design and more advanced scenarios this first version of Microsoft’s UML modeling tools hits its limitation. The first and most important limitation for using as a complete or advanced design tool is the lack of connection to the source code. Other tools like Enterprise Architect from SparxSystems or UModel from Altova can go the whole way and synchronize (round tripping) your design model and source code.
Even if I could model everything inside VSTS it is not much use going to that kind of detail, if I can’t reuse it to create code. Putting that much effort in a design model requires the ability to generate code and sync changes in code back to the model.
The second limitation or showstopper is the lack of import export features. Especially the capability to import models or code to the model makes it harder to start using it on an existing project. You basically have to create all your elements by hand if you want to use it on an existing project. It would be really useful to have the capability to import source code to generate classes in the model.
VSTS2010 features for understanding existing code
Even if VSTS2010 lack some vital capabilities as an advanced design first model tool, it has many advanced features for architecture and design. VTST2010 focus a lot on understanding your existing code, and the architectural explorer and the architectural tools provides good value and is worth a own post. When it comes to design and UML tools VSTS2010 has a great function for generating sequence diagrams from code, and beta2 promise to be even better, providing drilldown, comments and interactivity in the sequence diagrams making it even easier to understand the existing design.
Summary and reflections
I think that the VTST2010 modeling tools can provide a value in most projects, as a general UML tool or as a tool for analyzing and initial design. If you don't have a modeling tool today, or have an advanced tool you're not using to the full extent should definitely take a look at the model capabilities of VSTS2010. One good way is to stay tuned to Cameron Skinner's blog and his coming post on modeling in VSTS2010.
UML at the concrete level
The next step after requirements is usually to do some kind of analyzing and/or basic design as the first step towards the destination - real code. After the initial design the next step is to complete the design into a fully technical specification. Now days many projects tend to skip formal analyzing and initial design and go direct to coding. For the people who do go all the way there is/has been tools like Rational Rose/XDE, Enterprise Architect and UModel who could even go the whole way to generate code from the design.
VSTS2010 as an analyzing and initial design tool
Doing analyzing and initial design requires more of your tool than just fancy images. You need some kind of repository to share and reuse your discovered elements. VSTS2010 handles this through the UML Model Explorer. The model explorer act as an in memory repository making it possible to browse through your defined elements. You can organize your elements hierarchy in the model explorer by creating package.
In VSTS2010 you can create class, activity and sequence diagrams and drag and drop elements from the model explorer to your diagrams. Changing objects, like renaming classes or operations, updates all diagrams. It is also possible to promote object and messages to classes and operations. Basically it got most of the capabilities needed for analyzing and initial design of a system.
VSTS2010 as an advanced design first tool
When it comes to doing model first design and more advanced scenarios this first version of Microsoft’s UML modeling tools hits its limitation. The first and most important limitation for using as a complete or advanced design tool is the lack of connection to the source code. Other tools like Enterprise Architect from SparxSystems or UModel from Altova can go the whole way and synchronize (round tripping) your design model and source code.
Even if I could model everything inside VSTS it is not much use going to that kind of detail, if I can’t reuse it to create code. Putting that much effort in a design model requires the ability to generate code and sync changes in code back to the model.
The second limitation or showstopper is the lack of import export features. Especially the capability to import models or code to the model makes it harder to start using it on an existing project. You basically have to create all your elements by hand if you want to use it on an existing project. It would be really useful to have the capability to import source code to generate classes in the model.
VSTS2010 features for understanding existing code
Even if VSTS2010 lack some vital capabilities as an advanced design first model tool, it has many advanced features for architecture and design. VTST2010 focus a lot on understanding your existing code, and the architectural explorer and the architectural tools provides good value and is worth a own post. When it comes to design and UML tools VSTS2010 has a great function for generating sequence diagrams from code, and beta2 promise to be even better, providing drilldown, comments and interactivity in the sequence diagrams making it even easier to understand the existing design.
Summary and reflections
I think that the VTST2010 modeling tools can provide a value in most projects, as a general UML tool or as a tool for analyzing and initial design. If you don't have a modeling tool today, or have an advanced tool you're not using to the full extent should definitely take a look at the model capabilities of VSTS2010. One good way is to stay tuned to Cameron Skinner's blog and his coming post on modeling in VSTS2010.
Tuesday, October 6, 2009
VSTS2010 as a modeling tool
Earlier this week I had the opportunity to take the VSTS beta out for a test drive as a modeling tool. My task was to suggest and describe possible scenarios of usage for an external vendor. Luckily I had a virtual environment with vsts2010 beta at hand (I never leave home without it :) ) So I took vsts out for a spin as my modeling tool.
Communicating at an abstract level
The task was really to communicate, at a high abstraction level, complex scenarios and interactions between the user, part of our system and part of the vendor's system. After thinking about it for a while I decided to try a sequence diagrams to illustrate the interactions. So I started creating a new sequence diagram. Doing so was quite easy and in a couple of minutes I had my first sequence ready. But drawing a sequence diagram is only usefull if you can publish it. In order to do so I simply copied and pasted the diagram into my word document.
VSTS2010 as a basic UML drawing tool
As a drawing tool for basic UML illustration I must say VSTS2010 looks really good. Of course there are always things you miss or wish for, especially in a version one beta. My biggest issue was that I wasn’t able to change the icon for the objects in the head of the lifeline. The first overall impression is that it is easy to work with and have a good feeling as a drawing tool.
VSTS2010 as a requirements modeling tool
As it felt good as a drawing tool I got curious if it could be used more as a modeling tool in a project. One of the first things in a project is in most cases modeling requirements in some way.
In VSTS2010 modeling requirements is mainly done by creating use case diagrams. Once again it is fast and easy to create a use case diagram and populate it with actors, use case and systems boundaries. In VSTS2010 you can create (or link to ) a user story work item (or any other work item). This gives you a direct link from the high level model to the detailed requirements documentation. Another feature in VSTS2010 is that you can add artifacts to your use case diagram and link them to either work items or files in general. My colleague Clemens Reijnen wrote a post on this Enrich VSTA 2010 Use case diagram with SketchFlow Screens
Summary and reflections
I have many times over the years reflected over the lack of a good tools, or perhaps good enough tools, for UML modeling. Either you had a graphic library like Visio or a highly specialized tool for design with a steep learning curve, like Rational Rose/XDE. I hope and it feels like the VSTS2010 UML modeling tools could finally fill that gap and provide something in between Visio and the specialized tools. Let’s hope Microsoft package this so it can widely spread and used from all vsts editions.
Speaking about filling holes, I’m also impressed with the way it’s possible to tie together requirements modeling, specification and even test, out of the box in vsts2010.
In the next post I will take a look if and how the UML modeling tools in VSTS2010 can be used for analyzing and designing a system.
Communicating at an abstract level
The task was really to communicate, at a high abstraction level, complex scenarios and interactions between the user, part of our system and part of the vendor's system. After thinking about it for a while I decided to try a sequence diagrams to illustrate the interactions. So I started creating a new sequence diagram. Doing so was quite easy and in a couple of minutes I had my first sequence ready. But drawing a sequence diagram is only usefull if you can publish it. In order to do so I simply copied and pasted the diagram into my word document.
VSTS2010 as a basic UML drawing tool
As a drawing tool for basic UML illustration I must say VSTS2010 looks really good. Of course there are always things you miss or wish for, especially in a version one beta. My biggest issue was that I wasn’t able to change the icon for the objects in the head of the lifeline. The first overall impression is that it is easy to work with and have a good feeling as a drawing tool.
VSTS2010 as a requirements modeling tool
As it felt good as a drawing tool I got curious if it could be used more as a modeling tool in a project. One of the first things in a project is in most cases modeling requirements in some way.
Summary and reflections
I have many times over the years reflected over the lack of a good tools, or perhaps good enough tools, for UML modeling. Either you had a graphic library like Visio or a highly specialized tool for design with a steep learning curve, like Rational Rose/XDE. I hope and it feels like the VSTS2010 UML modeling tools could finally fill that gap and provide something in between Visio and the specialized tools. Let’s hope Microsoft package this so it can widely spread and used from all vsts editions.
Speaking about filling holes, I’m also impressed with the way it’s possible to tie together requirements modeling, specification and even test, out of the box in vsts2010.
In the next post I will take a look if and how the UML modeling tools in VSTS2010 can be used for analyzing and designing a system.
Monday, September 28, 2009
VSTS2010 team project creation - God and bad news
The good news is that VSTS2010 has the capability to script team project creation out of the box. Grant Holliday wrote a post on Scripting Team Project Creation in TFS2010. As Grant states, this is a step in the right direction, earlier we had to relay on the power tool command line utility for creating team projects.
The bad news is that the 2010 version for scripting team project creation requires some GUI interaction and the VSTS beta requires the team explorer tab to be selected the last time Visual Studio was closed. I also look like VSTS2010 can’t create team project for TFS2008 through scripting.
Hopefully this can be fixed before the RTM version.
The bad news is that the 2010 version for scripting team project creation requires some GUI interaction and the VSTS beta requires the team explorer tab to be selected the last time Visual Studio was closed. I also look like VSTS2010 can’t create team project for TFS2008 through scripting.
Hopefully this can be fixed before the RTM version.
Tuesday, September 8, 2009
VSTS 2010 Readiness
VSTS 2010 has been around for a while now, at least in some kind. It’s actually two years now, counting from the first Rosario CTP in August 2007. With Microsoft moving into beta 1 and soon beta 2 it feels like the time to get ready for the future is here.
As a first step for more serious effort I decided to do a test upgrade of our central TFS server, containing about 70 team projects. The goal was to test the upgrade process, and to get a real environment and real data for future tests. The install/configuration/upgrade process was a pleasant experience, running without any problems or errors. After upgrading I had to r run Hakan Eskicis script http://blogs.msdn.com/hakane/archive/2009/05/20/sample-script-to-enable-new-features-in-upgraded-team-projects-tfs-2010-beta1.aspx to enable my old team projects with the new features, hopefully this will be included in the upgrade process in the feature.
Overall the test upgrade went smoothly without any problem, and I can sleep better knowing it works. I also have lots of real life projects and data to put the new vsts2010 features to realistic tests. Hopefully I can start using the new vsts2010 toolset to solve real life everyday problems.
As a first step for more serious effort I decided to do a test upgrade of our central TFS server, containing about 70 team projects. The goal was to test the upgrade process, and to get a real environment and real data for future tests. The install/configuration/upgrade process was a pleasant experience, running without any problems or errors. After upgrading I had to r run Hakan Eskicis script http://blogs.msdn.com/hakane/archive/2009/05/20/sample-script-to-enable-new-features-in-upgraded-team-projects-tfs-2010-beta1.aspx to enable my old team projects with the new features, hopefully this will be included in the upgrade process in the feature.
Overall the test upgrade went smoothly without any problem, and I can sleep better knowing it works. I also have lots of real life projects and data to put the new vsts2010 features to realistic tests. Hopefully I can start using the new vsts2010 toolset to solve real life everyday problems.
Friday, August 21, 2009
TFS Admin, Part III - POC Extending TFS Warehouse
If I had a dollar for every time I wished for the capability to configure and store metadata about team project in TFS, I could at least take a very long vacation. Using a custom list in SharePoint to keep track of team projects and their metadata is the best solution I've come up with so far, especially if you use it as a request queue. But it´s still a non integrated solution causing manually work if you want to do reporting or anything useful with it.
Extending TFS Warehouse with metadata
Having metadata in a SharePoint list, which I could write code against, and knowing that the TFS warehouse is extendable gave me the idea to feed the TFS warehouse with team project metadata. For this to work I need the team project names to be the same in both the SharePoint List and TFS. This should not be a big issue for anyone, especially if you use the SharePoint list as a request queue and automatically create team project as described in previous post.
My plan was to write a generic adapter for the TFS warehouse, extending the Team Project dimension in the warehouse with selected fields from the SharePoint list.
Writing a custom TFS Warehouse adapter
My plan was to write a generic adapter for the TFS warehouse, extending the Team Project dimension in the warehouse with selected fields from the SharePoint list.
After some research on MSDN I was ready to start. A custom adapter is simply a class implementing the 3 methods in IWareHouseAdapter, compiled into an assembly and deployed to a special folder. To implement the IWarehouseAdapter interface you have to write code to make
• Make Schema Changes to the TFS Warehouse and cube
• Make Data Changes, i.e. create rows in the database
• Handle Initializing, request to stop processing
The TFS API provides an object model for the warehouse, together with some good articles on msdn and Steve Wrights posts How I built a Team Foundation Server custom data warehouse adapter made it pretty easy writing the adapter and deploying it to the server.
Retrospective - the real challenges
In retrospective I can see that the biggest challenges had nothing to do with writing the adapter or handling a SharePoint custom list. Looking back I spent more time doing other stuff then writing the logic for the adapter. The other things taking most time from the real task were:
Testing and the test environment
Running the test environment (a virtual PC image of o complete TFS setup) locally on my old and slow laptop were not funny. In order to save time, I tried reinitializing the TFS warehouse between tests. But this took too long time, so I ended up with reverting the virtual my machine and setting up my environment for every test run. Maybe a better design/separation and mocking could have saved time in the end.
Trying to make the Warehouse over complex
My lack of real world experience from BI projects took me out on long journey trying to make a too complex warehouse in order to handle the metadata in a generic way. After many hours trying to implement the advanced model with the TFS API I consulted a colleague with real life experienced of BI project and went for a really simple design instead.
Handling configuration for the adapter dll
Needing to store some configuration and have it easily handled I thought that using a .config file for the dll would be the best fit. I simply added settings to the adapter project and used the Properties. Settings class. Things worked nice until I tried changing the value in the .dll.config file. As I was afraid of it didn’t work. After hours of fruitless search for a way to get the framework to actually read my config file, I gave up and derived a custom setting provider from LocalFileSettingsProvider, override the GetPropertyValue method reading the config file as an XML document. Once I decided to write my own settings provider was I was done in 15 minutes, but I wasted several hours looking for a better solution.
Reducing technical dept
As I needed to wrap a SharePoint list in this project to I started to break out the SharePointListWrapper into a utility project. One thing lead to another and in the end I ended up fixing some of the code for the Automated Order Process to.
Doing so I repackage the source for The Automated Order Process, although the code is in better shape, it is like the TeamProejctMetadataAdapter still a proof of concept.

http://cid-5d46cae8c0008cf0.skydrive.live.com/self.aspx/.Public/POC%20TeamProjectMetadataAdapter.zip
Extending TFS Warehouse with metadata
Having metadata in a SharePoint list, which I could write code against, and knowing that the TFS warehouse is extendable gave me the idea to feed the TFS warehouse with team project metadata. For this to work I need the team project names to be the same in both the SharePoint List and TFS. This should not be a big issue for anyone, especially if you use the SharePoint list as a request queue and automatically create team project as described in previous post.
My plan was to write a generic adapter for the TFS warehouse, extending the Team Project dimension in the warehouse with selected fields from the SharePoint list.
Writing a custom TFS Warehouse adapter
My plan was to write a generic adapter for the TFS warehouse, extending the Team Project dimension in the warehouse with selected fields from the SharePoint list.
After some research on MSDN I was ready to start. A custom adapter is simply a class implementing the 3 methods in IWareHouseAdapter, compiled into an assembly and deployed to a special folder. To implement the IWarehouseAdapter interface you have to write code to make
• Make Schema Changes to the TFS Warehouse and cube
• Make Data Changes, i.e. create rows in the database
• Handle Initializing, request to stop processing
The TFS API provides an object model for the warehouse, together with some good articles on msdn and Steve Wrights posts How I built a Team Foundation Server custom data warehouse adapter made it pretty easy writing the adapter and deploying it to the server.
Retrospective - the real challenges
In retrospective I can see that the biggest challenges had nothing to do with writing the adapter or handling a SharePoint custom list. Looking back I spent more time doing other stuff then writing the logic for the adapter. The other things taking most time from the real task were:
Testing and the test environment
Running the test environment (a virtual PC image of o complete TFS setup) locally on my old and slow laptop were not funny. In order to save time, I tried reinitializing the TFS warehouse between tests. But this took too long time, so I ended up with reverting the virtual my machine and setting up my environment for every test run. Maybe a better design/separation and mocking could have saved time in the end.
Trying to make the Warehouse over complex
My lack of real world experience from BI projects took me out on long journey trying to make a too complex warehouse in order to handle the metadata in a generic way. After many hours trying to implement the advanced model with the TFS API I consulted a colleague with real life experienced of BI project and went for a really simple design instead.
Handling configuration for the adapter dll
Needing to store some configuration and have it easily handled I thought that using a .config file for the dll would be the best fit. I simply added settings to the adapter project and used the Properties. Settings class. Things worked nice until I tried changing the value in the .dll.config file. As I was afraid of it didn’t work. After hours of fruitless search for a way to get the framework to actually read my config file, I gave up and derived a custom setting provider from LocalFileSettingsProvider, override the GetPropertyValue method reading the config file as an XML document. Once I decided to write my own settings provider was I was done in 15 minutes, but I wasted several hours looking for a better solution.
Reducing technical dept
As I needed to wrap a SharePoint list in this project to I started to break out the SharePointListWrapper into a utility project. One thing lead to another and in the end I ended up fixing some of the code for the Automated Order Process to.
Doing so I repackage the source for The Automated Order Process, although the code is in better shape, it is like the TeamProejctMetadataAdapter still a proof of concept.
http://cid-5d46cae8c0008cf0.skydrive.live.com/self.aspx/.Public/POC%20TeamProjectMetadataAdapter.zip
Subscribe to:
Posts (Atom)