|
LockeNess Monster posted:Well in FASTA format N is supposed to mean that sequencer wasn't sure what nucleotide it was, so N is actually legit in input data. However also notice passing string by value, not consting it as well as method not being const and returning a brand new string. My point is that in any sane system, the uppercase command does not get to decide what is an invalid input from the sequencer or whatever. I sometimes deal with code written like this, and usually how slow the program is running is the last of the worries since you basically have to scrap it all anyway.
|
# ? Apr 26, 2010 00:45 |
|
|
# ? May 14, 2024 10:32 |
|
Why even bother doing that if all incorrect input is going to be set to "N" when you take it in (at least I'm assuming it should already be doing this).code:
jonjonaug fucked around with this message at 01:54 on Apr 26, 2010 |
# ? Apr 26, 2010 00:51 |
|
Shumagorath posted:I'm not sure what virtual memory has to do with that, but hasn't Microsoft been trying to bring this back for WinFS for a decade now and they just keep getting held up? WinFS is more than just single level storage in that it's got searching plus pretty much a full OO database with sharing and permissions and every bell and whistle that could possibly exist. SLS on its own simply treats disk storage as plain old memory and RAM as cache. Multics used both segmented and paged memory, and treated every file as a segment that could be mapped into a process space. File reading and writing was performed simply by reading and writing into that segment and the OS would handle it by mapping the pages to memory for reading and writing dirty pages to disk. Since modern operating systems already do have mechanisms like mmap, I guess that you could say that we do have SLS of a sort as an option although the flat memory space makes it difficult to map the whole file.
|
# ? Apr 26, 2010 07:49 |
|
Shoot, if you're doing a million of them and your input is sanitized, you could simply go:code:
jandrese fucked around with this message at 19:06 on Apr 26, 2010 |
# ? Apr 26, 2010 19:02 |
|
code:
|
# ? Apr 26, 2010 20:07 |
|
clockwork automaton posted:
This one is my favorite, haha.
|
# ? Apr 27, 2010 01:05 |
|
Ugg boots posted:This one is my favorite, haha. I don't have the code in front of me but a friend was doing some RPG style coding and basically made a giant exception list for items that don't pluralize generically. E.g. "pair of pantses" that looked like the above. Not many elegant ways to do it though; maybe identify the major sub-cases and use some kind of opcode to control pluralization behavior. (Already plural, ends in s, default plural, etc.)
|
# ? Apr 27, 2010 02:01 |
|
Scaramouche posted:I don't have the code in front of me but a friend was doing some RPG style coding and basically made a giant exception list for items that don't pluralize generically. E.g. "pair of pantses" that looked like the above. Not many elegant ways to do it though; maybe identify the major sub-cases and use some kind of opcode to control pluralization behavior. (Already plural, ends in s, default plural, etc.) You can store the pluralized name as a field with the item object and set it when creating the items; your tools can have a much dumber pluralization routine to set the default.
|
# ? Apr 27, 2010 02:07 |
|
code:
|
# ? Apr 27, 2010 19:02 |
|
Free Bees posted:
Right-click "create method stub for .." is exactly what happened there.
|
# ? Apr 27, 2010 19:15 |
|
jandrese posted:Shoot, if you're doing a million of them and your input is sanitized, you could simply go: I would write it as check.length and then if it was really eating a lot of time in the loop see if changing it would help. You are correct on the if statement if and only if you know the input data is correct and does not effect results later.
|
# ? Apr 27, 2010 20:30 |
|
HFX posted:I would write it as check.length and then if it was really eating a lot of time in the loop see if changing it would help. You are correct on the if statement if and only if you know the input data is correct and does not effect results later. Better yet: code:
code:
|
# ? Apr 27, 2010 20:45 |
|
std::strings can contain \0. You should be using iterators instead of random access if you're savagely optimizing. Do you have a problem with the standard library function toupper()?
|
# ? Apr 27, 2010 21:16 |
|
Mustach posted:std::strings can contain \0. You should be using iterators instead of random access if you're savagely optimizing. Do you have a problem with the standard library function toupper()? Iterators are faster than random access for std::string?
|
# ? Apr 27, 2010 21:21 |
|
jonjonaug posted:Better yet: You guys are missing the obvious optimizations your video card could be doing. This sort of parallel work is perfect for GPGPU/CUDA/etc. Just think how much faster this could run in such an environment!
|
# ? Apr 27, 2010 21:26 |
|
tractor fanatic posted:Iterators are faster than random access for std::string? Regardless, that kind of optimization is dwarfed by the function looping through the string at least twice: Once to copy the string and another to modify it. And maybe another time, depending on if the compiler can elide the return copy.
|
# ? Apr 27, 2010 21:52 |
|
Student code is disallowed in this thread, right? My group code-an-OS project has been the source of many horrors.
|
# ? Apr 27, 2010 22:01 |
|
jandrese posted:I'd also consider caching the result of check.length() if this is a critical loop. Your optimizer is smart enough to do it for you (but it might not, and you might be making a function call on every iteration). .length() will almost certainly be inlined, so you're not going to have much overhead even if it isn't cached.
|
# ? Apr 27, 2010 22:11 |
|
Mustach posted:Probably, if you're sequentially iterating through the characters. Of course, only a profiler can say for sure, but I don't see why I should assume that the counter-intuitive option is worse, especially when most implementations that I've looked at just typedef char*. If String is actually just typedef char*, then wouldn't the function pass by reference and avoid making the copy? Although if it is just a typedef, then string.length() could be an O(n) operation, which would make the whole function O(n^2) unless you went and cached the result. Then again, if \0 is a valid character for String classes, then it can't be a simple wrapper for a C style string, the length has to be stored somewhere.
|
# ? Apr 27, 2010 22:12 |
|
jandrese posted:If String is actually just typedef char*, then wouldn't the function pass by reference and avoid making the copy? MSVC strings look something like this: code:
|
# ? Apr 27, 2010 22:18 |
|
jandrese posted:If String is actually just typedef char* Mustach fucked around with this message at 22:26 on Apr 27, 2010 |
# ? Apr 27, 2010 22:21 |
|
First rule of optimization: assume that your compiler was written in 1983 by an army of white collared chimps with typewriters Second rule of optimization (follows from first): there's a massive difference between i++ and ++i, especially for primitives Third rule of optimization: god the neck of this bottle feels amazing in my rear end
|
# ? Apr 27, 2010 22:24 |
|
Painless posted:First rule of optimization: assume that your compiler was written in 1983 by an army of white collared chimps with typewriters
|
# ? Apr 27, 2010 22:30 |
|
Painless posted:Third rule of optimization: god the neck of this bottle feels amazing in my rear end
|
# ? Apr 27, 2010 22:34 |
|
code:
|
# ? Apr 27, 2010 22:44 |
|
Amusing anecdotes about systems programming on the VAX 11/780 are truly the fons et origo of all best programming practices.
|
# ? Apr 27, 2010 23:53 |
|
Painless posted:First rule of optimization: assume that your compiler was written in 1983 by an army of white collared chimps with typewriters Well those are good, but I prefer mine First rule is READ THE loving ASSEMBLY. Second rule is PROFILE YOUR loving poo poo. The third rule is interchange 1 and 2 as approrpiate.
|
# ? Apr 28, 2010 01:22 |
|
Ok, this stuff is from two of my teammates in my OS project. It's student code so you'd expect some level of shittiness but then again, it is a junior-level course. Also, if you don't know C you have no business calling yourself a computer engineer. On with the lovely code. Guess what this is doing (variable names changed slightly and extraneous code removed to highlight the horror) code:
(thing[i].file_name is a char array) String comparison! Because that's totally how string compare in C works. The next horror isn't about code itself. I had a continue; in my code somewhere and these two brilliant guys asked me where this "continue function" was declared. Think about that for a second. They thought that I was calling a function named continue, despite not having any parens and despire continue being highlighted by their text editors in the same color as every other reserved word. Finally, l'horreur finale with a little bit of code I can demonstrate. During a rush to get one our checkpoints done I wrote some somewhat hackish code. The same two teammates as before decided to "refactor" afterwards in an attempt to scrub off the hackishness. In particular, there was an issue where the assignment sheet happened to mention storing an inode_t * inside a file descriptor struct. I stored the inode_t itself because we have no memory allocation and there's no actual points based on storing a inode_t * instead of the inode_t itself. I figured that would be the last I'd ever hear of it but then I take a look at the code and see that they've gone through and changed all the inode_ts to inode_t *s without actually allocating any space! Worse yet, they changed code:
code:
The worst thing is that because we're in kernel mode this "works" most of the time for small tests. When I pointed this out, I saw the following change shortly afterwards. code:
tl;dr: 2 of my teammates manage to do negative work on this project. sadly i feel they're probably going to graduate with the same degree as me.
|
# ? Apr 28, 2010 03:04 |
|
Really that's all your fault though. You should have picked better partners.
|
# ? Apr 28, 2010 05:12 |
|
theg sprank posted:Really that's all your fault though. You should have picked better partners. The only good partner in university is no one at all.
|
# ? Apr 28, 2010 05:19 |
|
theg sprank posted:Really that's all your fault though. You should have picked better partners. From what I can tell these guys are roughly on average skill level for the course.
|
# ? Apr 28, 2010 06:22 |
|
BattleMaster posted:The only good partner in university is no one at all. I once had a professor who told me that I had to do one project individually since group projects amounted to having three people watch me do all the work.
|
# ? Apr 28, 2010 06:32 |
|
When I had a group project, I got stuck with the three other kids who were not turned on by all the other groups' stupid ideas. We ended up being the awesomest group. The end.
|
# ? Apr 28, 2010 06:42 |
|
1337JiveTurkey posted:I once had a professor who told me that I had to do one project individually since group projects amounted to having three people watch me do all the work. I always felt like such a retard for asking if I could do group projects by myself, but I sure as hell didn't want to explain, for example, in a Math class why I was writing a C# application to generate the linear equations for the linear programming problem. All of the other groups wrote out all of the combinations by hand (this was a scheduling problem.)
|
# ? Apr 28, 2010 07:17 |
|
Janin posted:Please tell me it involves genetics in some way code:
|
# ? Apr 28, 2010 09:33 |
|
Not sure if it qualifies, but what do you do when your programming language doesn't support bitwise operators? You create them from scratch. (search for "poor man's bitlib") I am particularly fond of their bitwise AND implementation: code:
|
# ? Apr 28, 2010 13:05 |
|
cowtown posted:
Find whoever wrote that and harvest their kidneys.
|
# ? Apr 28, 2010 14:48 |
|
1337JiveTurkey posted:I once had a professor who told me that I had to do one project individually since group projects amounted to having three people watch me do all the work. I once told a kit in front of the whole class that he couldn't be my partner because he sucked too much.
|
# ? Apr 28, 2010 16:02 |
|
http://everything2.com/title/C%252B%252B%253A+Checking+units+at+compile+time I love this
|
# ? Apr 29, 2010 01:56 |
|
|
# ? May 14, 2024 10:32 |
|
Then you'll love Boost MPL
|
# ? Apr 29, 2010 02:15 |