Calvin Hsia's WebLog

thoughts from a professional developer

Browse by Tags

Tagged Content List
  • Blog Post: See how often your code runs and how much time it takes

    Last post I showed how to create your own CLR profiler. This time, we’ll add a little code to run whenever a managed method is entered and exited. We’ll do this by signing up for the  Enter and Leave function hooks by calling ICorProfilerInfo2->SetEnterLeaveFunctionHooks2 . This will allow us...
  • Blog Post: Call managed code from your C++ code

    Over the decades of writing code, I’ve found that writing managed code (C#, VB) is much more productive than native code (C++). This is especially true due to the capabilities of the .Net framework libraries that can be used easily from managed code. For a given programming task, the number of lines...
  • Blog Post: Cartoon animation works great on Surface Pro

    I showed my 9 year old son a cool drawing program called Physamajig , in which users can draw objects, which behave like real physical objects, including reacting to gravity, friction, and bounce. He was having fun with it on my Surface RT and it reminded me of another program. Years ago (around 1981...
  • Blog Post: The Visual Studio Feedback tool

      Sometimes when you use Visual Studio, or any application on a computer, there’s a notable pause when you try to do something. For example, trying to access a file on a network share somewhere, perhaps on a slow connection, the application will seem to be unresponsive for a few seconds. Sometimes...
  • Blog Post: Compiling code at runtime and MVP program is 20

    This month marks the 20 th anniversary of the Microsoft MVP program, so MVPs were in the news. Apparently I had a lot to do with the founding of the program J Wikipedia: http://en.wikipedia.org/wiki/Microsoft_Most_Valuable_Professional Microsoft News: http://www.microsoft.com/en-us/news/features/2013...
  • Blog Post: Create a logger for watching your test progress as it runs.

      I was creating a project that’s a Windows Service, which has components running in multiple processes, using multiple threads and named pipes for communication. To understand the behavior of the code, I wanted to have accurate logging that: · The timing was very critical, so I wanted the log to...
  • Blog Post: Turn your tests into stress tests easily

    It’s great to be able to write tests and execute them while developing a project. While I’m developing, I can hit a button and run the dozens of tests to see if I’ve broken anything. As code gets written lots of things get refactored, moved around, etc. Hitting a button to see if I broke anything is...
  • Blog Post: The number of Garbage Collections indicate how much memory is used

    One of the performance improvements we made in .Net was with System.Text.StringBuilder . StringBuilder is used in lots of code to build strings: it has various methods to modify strings quickly. Once a string is built, the ToString method is called to create the string. We observed via MemSpect that...
  • Blog Post: Performance of Memory vs Disk

    There is a comment on this Visual Studio Blog post (about how we made Visual Studio faster): “Focus on speed, not memory usage. Memory is very cheap, but CPU performance is muuuuuuuuch moooooooore expensive.” Yes, memory keeps getting cheaper, but actually, reducing memory use is critical to increasing...
  • Blog Post: Increase the memory available to your tests

        I love having test projects included in my solutions. Software is alive. I’m constantly making improvements/changes/fixes. When I have customers asking for various features in my code, or for code improvements, being agile and able to publish a changed build with utmost confidence relies...
  • Blog Post: Create multiple threads to see if work is done simultaneously

    When you hear about threads and threading, you hear that they allow concurrent execution of code, which is supposed to lead to better performance. Most computers nowadays have more than one CPU, meaning that each CPU can be executing code at the same time. Hit Ctrl-Shift-Escape to bring up Task Manager...
  • Blog Post: Examine your program's available memory: is it leaking?

      Sometimes your program wakes up and finds itself running in an environment that might not be as suitable as you’d like.   For example, it might be distributed to a user running on a machine with not enough memory, and could be failing. Perhaps the failures occur because the user is running...
  • Blog Post: More fun with the Fast Fourier Transform

    The sounds that we hear can be recorded via a microphone and can be graphed as a signal of amplitude versus time. Low notes show as a lower frequency wave, and high notes show as higher frequency waves. Over the past few decades, some music players, like a car radio or stereo amplifier, have an “equalizer...
  • Blog Post: Automatic tests protect your code

      Last month   in   Dynamically create huge tooltips in WPF TreeView and ListView I showed some code that creates large tooltips to present lots of data.   Today, we’ll talk about creating automatic tests for this feature.   Testing User Interface features has been difficult...
  • Blog Post: Dynamically create huge tooltips in WPF TreeView and ListView

      Tooltips are useful. When the mouse hovers over a button a tip can indicate what happens when it’s clicked. The mouse move does not actually invoke the button, but can give information in a passive way.   Sometimes I want to make huge tooltips. This essentially gives more screen real estate...
  • Blog Post: Adding a new ADO.NET Entity Data Model "Error HRESULT E_FAIL has been returned from a call to a COM component"

    I tried adding a new ADO.NET Entity Data Model item to a VS 2010 solution, but I got this error message: Error HRESULT E_FAIL has been returned from a call to a COM component. It worked just a few days ago…hmmm…. I had another project open in another VS instance, and I had...
  • Blog Post: Why does your code take so long? Profile it!

    Why does your code take so long to run? How do you improve its performance? When examining code, it’s very difficult to know which piece takes the longest, and thus should be the target of you optimization efforts. For example, you won’t see much benefit from optimizing a part of your...
  • Blog Post: Using multiple heaps efficiently

    You can inspect the processes that run on your machine using Task Manager (Ctrl-Shift-Escape) or , Process Explorer from Sysinternals Or you can write your own: here’s source code: What is your computer doing with all that memory? Write your own memory browser (if you’re using Dev10...
  • Blog Post: You can develop code faster

    You can make your Visual Studio experience faster. Often you write some code in Visual Studio, hit F5 to test the code. Repeat. Here’s a simple way to make this experience faster. (works with managed, native, mixed code). When a process is started from the debugger, it is started with...
  • Blog Post: Look at some hdden code in your VB project

    Some code is always added to your VB project. Try this: Start VS (2008 or 2010 beta: the numbers below are for 2008) File->New->Project->VB->Console App. Build->Build Solution. (I like to use temporary projects: see Use temporary projects in Visual Studio . I’m...
  • Blog Post: Make your Task Switcher Window bigger

    One of the best features of Windows is the ability to Cut and Paste data within an application or from one application to another. You can alt-tab or click on the task bar to switch between actively running applications, like Word and Visual Studio. When you hit Alt-Tab, a window comes up. ...
  • Blog Post: Process Explorer and Process Monitor can help you understand a program

    Process Explorer and Process Monitor are must-have free utilities that you can download from http://technet.microsoft.com/en-us/sysinternals/bb795533.aspx For example you can use ProcExp to examine a particular behavior of Visual Studio. Start Visual Studio (any version). I was using VS 2008...
  • Blog Post: You can use Visual Studio to debug itself!

    How do you find out why your computer or a running program is so slow? Here’s one way. Let’s attach the VS debugger to VS itself. The main executable for VS is devenv.exe. Start Visual Studio 2008. This will be the “debugger” Choose File->Open Project C:\Program Files\Microsoft Visual...
  • Blog Post: Write simple Debug helpers to help you debug and maintain your code

    Much of my time is spent using the Visual Studio debugger examining code to figure out how it works and how to fix it. When stepping through a function, the values the function uses are very useful for code understanding. The debugger shows these values in the Watch/Locals/Auto/Callstack windows. For...
  • Blog Post: How fast is interop code?

    How fast is interop code? If you’re in one kind of code and your calling another, what is the cost of the interop? For example, .Net code can call native C++ code (like Windows APIs) and vice versa. Similarly with Foxpro and C++ code. .Net code is often referred to as Managed code because much...
Page 1 of 2 (45 items) 12