You can still make this function faster and gain another second if you don't use IEnumerable and an enumerator but for example a List<int>
public static List<int> Primes(int upperLimit)
{
var result = new List<int>();
if (upperLimit < 2)
{
throw new ArgumentException("Upper ...
I'm not saying he's wrong, I am saying that his code is my code + his changes with no credit towards my efforts. If that's the case, then I'll just drop a comment that asks him to clarify that it is an improvement on my answer.
@EBrown Something like: "Upon reading your answer, I've noticed that it is an improvement upon mine. As per the [help section link], you should give attribution to the writter of the original answer"
I just didn't want the 10-12 hours of work I put into optimizing the question to go to waste, and be swept under the rug by someone who picked it up, changed a minor thing, and then submitted a revised edition under their own name.
The comment alone gives me enough satisfaction to make sure that it is clear that the answer he supplied was an improvement upon mine.
He's probably just used to forum tactics, where this would likely have been completely acceptable. (Except maybe quoting my answer for context, as well.)
I'm not that worried about it, but if I had done what that author did and it was wrong, I would want someone to point it out and clarify that it just requires one more step to be acceptable.
His code is 80% the speed of mine, except it's substantially different from the OP's.
Just benchmarked it (in the exact same manner as the OP code and my code), and his is 2078ms, mine is 2488ms, OP is 3957ms. (That's the fastest out of two runs.)
I have this query here that I am trying to make more efficient as it is taking an extremely long amount of time, about 40s on 3 million records.
The query basically takes X amount of rows per company and turns them into columns for a given existing column.
SQLFiddle
SET @sql = NULL;
SET @sql1 ...
@CaptainObvious it is taking an extremely long amount of time, about 40s on 3 million records. Am I the only one who thinks 3 million records in 40s isn't bad at all? Unless that query is executed multiple times an hour, leave it be...
But the user should be warned so he doesn't repeat that
I don't want to steel anyone's credits for optimizing the code but just to show another option that should be considered while optimizing for performance. — t3chb0t59 secs ago
For example, @IsmaelMiguel, say you are enumerating, and you just want the first prime of 8 digits, for example. With my code (and OP's code), you can do something like:
I cannot think of anything to make it faster.
However, recursion along with some sort of polymorphism and (optionally) visitor pattern can give you the same result without nested loops. Here is an simplified example based on static polymorphism (my code is more abstract than yours but is complet...
So I need a little help. It is currently working but I might have over complicated it. So maybe someone has a better idea. Now let me try and explain it.
I am trying this query, and it currently works but I am not sure if it is the best way to do this.
I have a table that reads every minute, ...
Is it possible to build a table of code review performers? Like how many made by each user (the most, the least) in a given period of time? Is there a database I can simply fire up a SQL(-like) query?
I thought this should work:
<?php while($get_service = $dbh->query('SELECT id, name, description, duration FROM services WHERE available = 1')->fetch()): ?>
<input type="checkbox" name="service[]" value="<?=$get_service['id']?>"> <?=$get_service['name']?>
<?php endwhile; ?>
But turns out i...
After installing Visual Studio 2012 and opening my solution I get a series of errors in this form:
The Web Application Project Foo is configured to use IIS.
Unable to access the IIS metabase. You do not have sufficient privilege to access IIS web sites on your machine.
I get this for each...
@RubberDuck Including: "For anyone that comes here later I solved this problem by turning off the IIS and .Net Framework features within Windows 7 and then turning them back on. Somewhere in that re installation it fixed my problem."
My dad has to pick me up at work tomorrow (~1.5 hour drive) because the insurance company has now, twice, been wrong about when they would have my car fixed.
This is literally the most inconvenient thing I have ever dealt with.
Write a menu-driven program to represent Polynomials as a data
structure using arrays and write functions to add, subtract and
multiply two polynomials; multiply a polynomial with a constant, find
whether a polynomial is a “zero” polynomial, return the degree of the
polynomial. Assume ...
He won't be back in the office until Tuesday. Now mind you, he said my car would be done this Friday, and now it won't be, and I only found out because I had to call the body shop directly.
you should set up a site on the full IIS from your machine and have the source be the debug folder. then you go into the project properties I think and set the .....
been a while since I had to do it that way, give me a second
there is a way to debug the site through IIS on your machine and not through the Visual Studios IIS
then you change it to local IIS under the servers section.
I would make sure that these settings are what you need them to be
I'm voting to close this question as off-topic because it's asking for a review of working code, which would make it more suited to codereview — Simon MᶜKenzie13 secs ago