Is it possible to profile line-by-line in .NET? [closed] - c#

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have a bit of an interesting question here about performance and was wondering if there was any way to do what I want to do:
I'm dealing with a large code-base (10,000+ lines), I want to run the code and get a visual analysis of what lines takes up the most time in the code. Like for example, is there anything that can highlight the lines of code that take up the longest amounts of time in .NET and/or give you a time spent on each line? In my mind, I'm visualizing something simple, like a green, yellow, and red highlight for each line of code and perhaps an amount of time that tells you how long each line took to run.
One way to get times would be through the Stopwatch, but its such a pain to have to have to add Stopwatches over and over again. How could I go about profiling my codebase like this? Does Visual Studio or .NET have anything out of the box for this?
Edit: Thanks to Patrick, I found out about ANTS, which does exactly what I wanted above (also shows HOT! lines in red in another window - lines that take up the most time...FYI: this isn't a profiler advertisement; I just required a line-by-line profiler for my needs and this does the trick so take it or leave it):

It's called a profiler, and there are many of them.
Some Visual Studio versions come with built-in analysis tools. Another tool I commonly use is ANTS Performance Profiler.
They sample which method is active (sampling), or even collect info on a per line / statement basis (instrumentation), depending on the settings used. You can use that to check what lines are most commonly used, or what lines consume most time each.
As a sample, take a look at the images in my question regarding statistics acquired from profiling.

Related

Organizing sound files [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
This question is actually a theoretical one, not about specific coding, but of the approach.
In my video game, there are a lot of phrases that protagonist is supposed to say. Now, I want to add a voiceover, so that someone will read those phrases aloud, so I can add them as sounds, not just plain text.
There are many different phrases.
So, the main question is, what's better, to have each phrase as separate sound file, or to have those phrases divided by sections (like game areas, or game actions or whatever), where each large file will contain a number of phrases. Then, in code, I'll order to play the large file not completely, but from specific time, to specific time (is it possible in WPF?).
What is important:
Time - which approach is easier to do?
Resources - which approach is easier for computer and\or visual studio compiler?
Copyright - I want to limit the possibility of end users stealing sound files.
I personally think that having a thousand of files is crazy, so it's better to use larger files that contain smaller ones. However, my friend highly recommended against it, claiming that playing large files from the middle is harder for computer and will cause problems, maybe slow down the game.
What option will you recommend? Or maybe there is another approach I didn't think of?
Thank you in advance,
Evgenie
I would imagine that using seperate sound files would be easier. Then within c#, add them all to a list.
From that I think it should just be possible to call the index of each sound file, which would be easy if you keep them organised, and labeled well.

How would I go about adding tabs to partition blog posts in an MVC application? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Alright, so let me elaborate since I'm not totally sure how to ask this question (perhaps why I have found nothing to help me). When I am adding posts to my website, I want to be able to say "Alright, that's ten posts, time to start a new tab". These tabs are what you typically see on a website when there are multiple pages of content. I am using C# with the MVC framework and my content is being stored in a localDB, it is currently being loaded by going through the model and displaying each item in the model. Side note, if my terminology sounds off or whatever, that's because I've only used C# for about a month now (my background is C) so my apologies for that. I just feel like it's such a common feature that it can't be that massively complex to do, I'm just not totally sure how to do it...
I'll quickly list a few of the things I have tried, I thought to myself if I can figure out how many rows there are in the database, divide that by how many articles I want to display per page, that will give me the tab count, which I could then say alright, once you've displayed this many articles, create a tab and continue where you left off. I tried and failed due to a lack of knowledge (I don't know where to look for something so specific). I tried other minor things but quickly realized they would not work. I'm not sure what code people would want to see (I'm assuming it's more just here's what we typically do) so if any code is needed I'm more than happy to post it.
Thanks so much in advance, typically I don't go online asking for help (This is my first time asking for help ever actually) but I am really just stumped on this.
With tabs, you are dealing with a finite amount of data. For example, input forms on a screen with each tab that represents a different category. From a user's perspective, having an infinite number of tabs to go through is rather painful.
I'd recommend looking into pagination as #Rowan mentioned. Sounds like that's more of what you are looking for. You break the posts into "pages" that lets the user navigate through content.

Pause Time in Windows [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I am trying pause time using C#/.NET. I am able to set the time but I would like to set the time to pause.
Does anyone know how to do this?
Command Prompt suggestions would also be helpful.
I'm using Visual Studio 2010 if that matters.
For testing? or real life?
For testing you can mock DateTime.Now (although it is easier to have an IClock interface). For real usage - I just wouldn't.
Or do you just mean Thread.Sleep?
I think you are talking about stopping windows time, I imagine this is a not a feature of windows to do this.
What are you actually tryting to achieve (other than break windows) there may be alternate solutions.
Well, I'm not sure why you'd want to do this, but, since there is no such thing as a 'PauseTime' function in windows, why don't you just have a service that marks the current time, and then continously sets the system time to that start time. That should achieve the effect of keeping the system time the same.
If you need to find out elapsed time for some debugging work, there's the System.Diagnotics.Stopwatch class. The page on MSDN has some decent examples on how to use it. I don't know what type of precision you're looking for, so maybe this isn't the class to use if you're looking for high performance timing diagnostics.
Hope this helps!

How can I improve my first OSS project [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am still visiting school and will finish my exams next year. Since two years I am working as (the only :-( ) in-house dev for a company providing financial services to Laboratories and doctors. After spending the first year fixing their existing Application and realizing, communicating and agreeing that it won't meet future requirements i rewrote it from scratch. This is my first LOB application.
I needed a "IEnumerable.ToDataTable()" method to do simplify certain things in the Application. I realized that existing solutions wouldn't meet my performance and flexibility requirements, so i came up with a solution based on Dynamically injected IL code myself.
I thought that this might be a good way to contribute to the community, thats why i asked my employer if i may take some of those code and release it under LGPL. They agreed and that's where my first project is:
ModelShredder
Since this is my first OSS project and i am relatively unexperienced with running an OSS project on my own I am asking you for some "best-pratices" and what i can improve on it.
First read this book:
You can download it free of charge here: http://producingoss.com/ There are also some nice screencasts there that may be some use too.
It covers everything you need to know about looking for, contributing to, starting and maintaining an open source project,
It all depends on if you're going to have a team help you or not. It'll be simpler to start doing it yourself if you have the time if for no other reason than you can work out how you want to proceed without worrying about politics.
For a start, any code used as a framework or a library typically needs to be developed to a much higher standard than what you might write for an internal application. This means you need:
Sufficient user and developer docuemtnation;
Unit tests with decent coverage;
A license;
Tagged versions in source control; and
Released binaries and source code with checksums.
Additionally you'll need a method of:
Communicating your project status (release notes, goals, etc); and
A means to allow people to raise and track issues.
Google Code (as just one example) can do pretty much all of this for you.
I would also suggest you register the domain name for your project (typically projectname.org for open source). If the one you want is taken already, you may want to change the project name, particularly as there might be cause for confusion.
The google code pages look pretty good to me. You might want to think about adding a support group on Google Groups.

What should I do to keep a tiny Open Source project active and sustainable? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
A couple of months ago I've coded a tiny tool that we needed at work for a specific task, and I've decided to share it on CodePlex. It's written in C# and honestly it's not big deal but since it's the first project I've ever built from scratch in that language and with the goal of opening it from the very beginning, one ends getting sort of emotionally attached to it, I mean you'd wish that the people will actually participate, be it criticism, bug reporting, or what have you.
So my question is, what can I do to actually encourage participation, stimulate curiosity or just recieve more feedback about it?
By the way this is the project I'm talking about: http://www.codeplex.com/winxmlcook/
You should:
Promote it where you think it would be relevant (forums,mailing lists etc.). Try not to spam though - it will create a backlash.
continue to provide updates as to create the appearance of an active project until more people pick it up.
Find project leaders, they are the sort of contributors that encourage others to contribute as well.
Blog about it and link to relevant blogs (creating ping-backs). Also leave comments at relevant blog posts.
Basically, your generic Internet marketing tactics ;)
You first have to acquire users by marketing the tool. Once you have users, that naturally means you'll start getting feedback.
One thing I noticed is your project description doesn't sell the project well. For example, type "winxmlcook" into Google, what gets shown is your project description but it's not likely to get someone to click on it.
I know I sound like a broken record constantly posting this book, but just about everything you could ever need to know about running an open source project is here. In particular, pay attention to these two chapters:
Getting Started
Managing Volunteers

Categories

Resources