ephemeral garbage
Member
have you tried using the performance tools? maybe you're allocating a lot of ephemeral garbage in a tight loop or similar?
I'm looking into them now, but I'm not exactly sure how they work.Not A Fur said:have you tried using the performance tools? maybe you're allocating a lot of ephemeral garbage in a tight loop or similar?
iapetus said:...
Instead, give them a simple task to implement. Fizzbuzz is fine. Implementing equals() in Java is fine. If they don't know what they're supposed to be doing, tell them the spec.
Then make them justify their implementation. Tell them it's not efficient enough. Add extra constraints on it.
For example, most people will use % (or the equivalent in the local currency) to implement Fizzbuzz.
Code:for (int i = 1; i <= 100; i++) { if (i % 15 == 0) { System.out.println("Fizzbuzz"); } else if (i % 5 == 0) { System.out.println("Buzz"); } else if (i % 3 == 0) { System.out.println("Fizz"); } else { System.out.println(i); } }
Tell them the three % checks are too inefficient for your high-speed Fizzbuzz app on low-powered devices, and that they have to implement it more efficiently.
Drkirby said:I sadly can't think of a way to make that fizzbuzz better :/
I worked with XNA a tad, post your code or a link to it.Ecrofirt said:Rant:
The goddamn XNA game I'm working on is pissing me off. I'm getting terrible framerates and I can't explain why at all.
Hell, I've only got a total of 12 sprites on screen, and they're all using the same damn texture.
I've tried with both displaying them and not displaying them, and the framerate bounces around. God forbid I attempt to move them at all, or it consistently dips below 60fps.
What in the blue fuck!
Ha! Do this at your own peril.diddles said:I've been in aggressive interviews where the guy was asking questions about stuff he wasn't even really comfortable with (physics math, advanced 3d rendering techniques, stuff he obviously just read up on to formulate a challenging question) and i turned the tables by answering and then asking him more questions about the subject that he implied he would be able to answer by asking me the question in the first place. pretty funny to turn the tables and have the interviewer turn into a stuttering sweaty nervous mess. One of those interviews ended up in me not getting the job![]()
The one iapetus referenced? The "Fizzbuzz" check is unnecessary. Just don't do an elseif check. You output Fizz if it's divisible by 3, and buzz if it's divisible by 5. You don't need to check for divisibility by 15.Drkirby said:I sadly can't think of a way to make that fizzbuzz better :/
diddles said:you could just loop individual counters for each special print, like if (++i2 == 5) { i2 = 0 and print whatever } instead of doing modulus's on a single counter. much faster on most hardware.
or you could make a precalculated global lookup table of 100 funtion pointers for each iteration and jump to the right one for each index assuming you have function pointer support in your lingo![]()
Drkirby said:I worked with XNA a tad, post your code or a link to it.
Steve Youngblood said:The one iapetus referenced? The "Fizzbuzz" check is unnecessary. Just don't do an elseif check. You output Fizz if it's divisible by 3, and buzz if it's divisible by 5. You don't need to check for divisibility by 15.
Was no other variable a requirement? If so, then this is what you get for skimming threads in a haphazard fashion. I was just trying to get rid of the third modulus check.Zoe said:How would you output the int when it's neither then without maintaining another variable?
Steve Youngblood said:Was no other variable a requirement? If so, then this is what you get for skimming threads in a haphazard fashion. I was just trying to get rid of the third modulus check.
Zoe said:It's not a requirement, but it strikes me as more wasteful than the extra check.
Drkirby said:I worked with XNA a tad, post your code or a link to it.
void FizzBuzz(int START, int END) {
Debug.Assert(START>0); Debug.Assert(END>START);
string[] fb = new string[15];
for( int i = 0; i < fb.Length; i++ )
fb[i]=null;
fb[2] = fb[5] = fb[8] = fb[11] = "fizz";
fb[4] = fb[9] = "buzz";
fb[14] = "fizzbuzz";
for( int i = START, j = (i-1)%15; i <= END; i++, j++ ) {
if (j==15) j = 0;
Console.WriteLine(fb[j] ?? i.ToString());
}
}
Zoe said:It's not a requirement, but it strikes me as more wasteful than the extra check.
nickcv said:i just finished speaking about the last guy of the day (tomorrow i'll have two more)
and i really didn't like his attitude.
he clearly knows what he is doing but he did some rookie mistakes.
- he talked trash about his last boss.
- he started fizzbuzz test but then didn't want to complete it saying "you can fill the rest of it"
he was doing it right, but i don't think i want to work with someone so arrogant.
shadowcomplex said:Ecrofirt, might wanna use something like paste bin next time.
AbortedWalrusFetus said:I never liked this. If you disqualify someone for this you are bad at interviewing, ESPECIALLY if you asked why they are seeking a new position/why they are leaving their current employer.
But anyone who has taken an architecture class knows that reading from memory is slower then just about any mathematical operation. Modulo is a built in function in CPUs that can be done in one clock cycle.ultron87 said:Well if the reviewer says to consider modulo as the expensive operation than you can do it with just the two checks and a flag variable to tell whether to print the number.
I think I'd prefer to see someone do it the two check way since it suggests an understanding of how to use ifs instead of just following the question and setting up an if statement for each possibility it mentions.
Drkirby said:But anyone who has taken an architecture class knows that reading from memory is slower then just about any mathematical operation. Modulo is a built in function in CPUs that can be done in one clock cycle.
Also, I think there's a tendency to respect the chain of command. Whether one is absolutely painting the 100% truth with their tale of managerial incompetence, to the interviewer, it still may appear that this individual is an arrogant, young hotshot who doesn't respect authority. Whether justified or not, most people don't like newbies coming in preaching "better" practices, and I might -- perhaps erroneously -- suspect that this individual was such a person.Kalnos said:If they say: "I chose to stop working at company 'x' because.... good reason" then yeah, that's no problem assuming the interviewer asked.
However,
If they say: "My boss couldn't code his way out of a box, his company was worthless hurr" then that probably isn't going to land you a job.
He said "trash talked" so I'm assuming something more like the second.
ultron87 said:Well if the reviewer says to consider modulo as the expensive operation than you can do it with just the two checks and a flag variable to tell whether to print the number.
I think I'd prefer to see someone do it the two check way since it suggests an understanding of how to use ifs instead of just following the question and setting up an if statement for each possibility it mentions.
for (int i = 1; i < 101; ++i) {
String result = "";
if !(i % 3)
result += "Fizz";
if !(i % 5)
result += "Buzz";
if !(result.size())
result += i; // yeah, I know this part doesn't work
System.Out.println(result);
}
Even then, you would have to first do a store of the value, then a load. You would be right back where you started.jman2050 said:Why wouldn't the compiler use a register in that situation?
for (int i = 0; i <= 100; i++)
{
bool FizzBuzz = false;
if (i % 3 == 0) { cout << fizz; FizzBuzz = true;}
if (i % 5 == 0) { cout << buzz; FizzBuzz = true;}
if (!FizzBuzz) cout << i;
cout << endl;
}
Drkirby said:Even then, you would have to first do a store of the value, then a load. You would be right back where you started.
I like to ask "What was your last boss's biggest failure?"Steve Youngblood said:Also, I think there's a tendency to respect the chain of command. Whether one is absolutely painting the 100% truth with their tale of managerial incompetence, to the interviewer, it still may appear that this individual is an arrogant, young hotshot who doesn't respect authority. Whether justified or not, most people don't like newbies coming in preaching "better" practices, and I might -- perhaps erroneously -- suspect that this individual was such a person.
/* Hi here is my Oblig3 which has one small problem that is little confusing for me with null objec that makes my waiting list to function when
* i call it again it shows some error and sometimes i get "NullPointerException which is about null object and little complicated with String object
* i do hope you will help me with it please as usual write to me all the comments you would say (maybe you don like how i write in english or
* without easyIO :-) Joke!!! ok Thank yo checking.
* /*////////////////////////////////////////////////////////////////////////////////////////////////////////
It depends on the CPU implementation.jman2050 said:But you'd have to do that anyway, since the result of the modulo operation has to be stored before it can be used in a comparison. At least that's how I understand it.
Ver x.x.4 - 7/2010
Ver x.x.3 - 6/2010
Ver x.x.2 - 5/2010
Ver x.x.1 - 4/2010
Ver x.x.2 - 1/2011
Ver x.x.3 - 2/2011
Clearly it means nothing changed.Zoe said:So at my company QA doesn't have access to the version control system, so we're dependent upon comments (if SQL) or release notes to figure out what's been changed.
This is what's in the files I'm looking at right now:
Code:Ver x.x.4 - 7/2010 Ver x.x.3 - 6/2010 Ver x.x.2 - 5/2010 Ver x.x.1 - 4/2010 Ver x.x.2 - 1/2011 Ver x.x.3 - 2/2011
Really dude?
Drkirby said:It depends on the CPU implementation.
Really, we are arguing over what could at best amount to one or two clock cycles. Overall both take about just as long. Is there some sort of Fizzbuzz solution that will uses even less commands?
ronito said:I like to ask "What was your last boss's biggest failure?"
That typically will tell you if they're arrogant or well thought out or whatever.
Then I ask what they'd do to mitigate it if they had the power.
I've done at least 1 interview per month for the past three years. When it's busy it's more like 1 every two weeks. So I've had plenty o' time to come up with stuff.nickcv said:ronito are you available to make a job interview class?
how many times did you do it to master it that way?
anyhow the dude started talking trash about his boss all by himself, no one asked him about it.
We should have a GAF programmer interviewing orgy.ronito said:I've done at least 1 interview per month for the past three years. When it's busy it's more like 1 every two weeks. So I've had plenty o' time to come up with stuff.
#include <iostream>
using namespace std;
int main()
{
char text1[] = "hello";
char text2[] = "jimmy";
cout << "Before: \n" << text1 << '\n' << text2 << endl;
char* p = text1;
char* q = text2;
// asking why and how this line works!
while (*q++ = *p++);
cout << "\nAfter: \n" << text1 << '\n' << text2 << endl;
cin.get();
return 0;
}
ronito said:zoe, how do you keep from going ballistic?
Spoo said:I suppose if you're hiring for C or C++ programmers, the following could be a fun question to ask. I read about it in Joel Spolsky's book and recognized it immediately since I've had more hands on time with C++ than anything else:
I realize that copying like this is actually kind of archaic-looking, but you have to know your stuff to follow the logic of that one line :\
#include <iostream>
using namespace std;
int main()
{
char text1[] = { 'h', 'e', 'l', 'l', 'o' };
char text2[] = { 'j', 'i', 'm', 'm', 'y' };
char text3[] = "hello";
char text4[] = "jimminy";
cout << "Before: \n" << text1 << '\n' << text2 << endl;
cout << text3 << endl << text4 << endl;
char* p = text3;
char* q = text4;
while (*p++ = *q++);
cout << "\nAfter first loop: \n" << text1 << '\n' << text2 << endl;
cout << text3 << endl << text4 << endl;
p = text1;
q = text2;
while (*p++ = *q++);
cout << "\nAfter second loop: \n" << text1 << '\n' << text2 << endl;
cout << text3 << endl << text4 << endl;
cin.get();
return 0;
}
If they say: "I chose to stop working at company 'x' because.... good reason" then yeah, that's no problem assuming the interviewer asked.
However,
If they say: "My boss couldn't code his way out of a box, his company was worthless hurr" then that probably isn't going to land you a job.
struct randomStruct {
int a;
bool b;
short c;
__int64 d;
bool e;
};