Java vs. C — inspired by an interview question, I wrote a little bit of sample code to create an array of a billion random integers, and either (A) take the sums as I go, or (B) go back over and sum it on a second pass.
In C (cygwin, gcc 6.4.0 64-bit):
– summing as I go, about 3.7 seconds on my laptop, -O3 doesn’t make much difference
– two passes, about 6.5 seconds unoptimized, about 4.1 seconds with -O3
– time to malloc(sizeof(int) * 1000000000) < 1ms
In Java (jdk 10):
– summing as I go, about 12.1 seconds
– two passes, about 13.4 seconds
– time to new int[1_000_000_000] about 1.7 seconds
So Java sucks, right?
Replaced random integer with consecutive integers, all in two passes:
Java : 2.7s
Unoptimized C: 6.1s
C at -O3: 2.1s
Given how much of that time is the equivalent of malloc in Java zeroing the memory, that’s pretty impressively fast.
So the real issue seems to be that Random.java is WAYYYY slower than rand()?
Last year, I posted this on my feed on Facebook; since that’s friends-only, I thought I’d repost it here on the anniversary of this rather regrettable milestone.
As most folks know, Trump is the oldest President at his inauguration, beating out Reagan by about 8 months (Reagan was not quite 70, Trump almost 71).
What others may not have realized is he’s also an exceptional President in other ways:
* He’s the first time a third President has been born in the same year (with Clinton and Bush Jr, all three born in 1946)
* He’s the oldest jump from his predecessor both at age at his inauguration, but also in age inauguration-to-inauguration.
More presidential age trivia
Continue reading “Some presidential age trivia.”
Out of curiosity, I decided to run some quick (and non-repeated, largely unscientific) benchmarks of a Gentoo (-march=native,etc etc) OpenJDK/IcedTea build vs. actual Sun/Oracle JVM builds. Interestingly, the Gentoo builds are slower. Unsurprisingly, the JVM gets noticeably faster across versions from 1.6->1.7->1.8
Continue reading “JVM performance over time”
OK, so I ran into my old web page from 1995. BOY was I callow as a 19 year old, although I suppose it’s a tautology to say so. Still, I ran into a few cool things I wrote when even younger than that… which I’ll be sharing here. First up, written in 9th grade, for a class project, I give you:
Little Red Riding Hood, as told by Holden Caufield
(actual text below the break; warning for those bothered by it, some mild profanity.)
Continue reading “Another brief bit of fiction”
Interesting article in The Guardian:
Experience: I was nearly drowned by a sea lion
What Trish hadn’t seen was that at the moment she said “Smile!” a sea lion had leapt about 7ft out of the water to get the fish, and grabbed my left hand in the process. Sea lions have canine teeth, just like a dog. It dragged me headfirst into the water. I’d actually seen it out of the corner of my eye a split second before I felt the pain. It was big and had such strength. It pulled me straight down to the bottom of the bay, about 25-30ft.
Sea lions are so agile. I don’t buy the idea that it accidentally got my hand; I think it was angry and territorial. The supply of fish here is dwindling and their numbers are increasing – there’s not enough food for them all.
Quite a bit more there. Go read it, amazing survival and interesting incident for an animal many of us think of as “cute.”
Pity Colbert isn’t back on the air yet. I’d love to see his take on it.
I love the title of this article: “
¿Por qué SystemD es una mierda?
Too tired tonight to read the whole thing in Spanish — I’ll feel dumb if the implications of the title aren’t their point — but wanted to share somewhere. Disabling the FB/Twitter publicize for this one for obvious reasons if you can follow the literal translation.
Mitt Romney expects to be ‘beaten but unbowed’ after Evander Holyfield bout
Mitt Romney and Evander Holyfield weighed in for their charity boxing match on Thursday night, with the former Massachusetts governor predicting a similar outcome to that of the 2012 presidential election, which he lost to Barack Obama.
Robot Chicken: The World’s Most One-Sided Fistfights
This guy is dead wrong… ran into this article a year ago, and posted the following comments on FB:
How ‘Star Wars’ ruined sci-fi
The six “Star Wars” films have been enormous successes: they have grossed over $2 billion domestically at the box office, spawned scores of books, comic books and merchandise (how many kids have their own light saber?) and made household names of characters like Darth Vader, Han Solo and Luke Skywalker.
They’ve also been the worst thing ever for the science fiction genre.
Instead, I’ll queue up “The Matrix,” and enjoy the most original sci-fi movie of the past 25 years. I recommend “Star Wars” fans do the same. They need to be reminded what real creativity is all about.
Star Wars is, like a great many other SF films before it, a pretty generic adventure story with an SF setting.
Not too different from Forbidden Planet (though cribbed from Kurosawa rather than Shakespeare) just as the Day the Earth Stood Still was a mild thriller with SF elements (and arguably cribbed from Christianity) as well as myriad less well remembered options. Star Wars’ only fault is its enduring success.
Meanwhile, he loses all credibility when he calls The Matrix the most original SF film of the past 25 years… it’s a VISUALLY stunning film, one of the high points of the late 1990s but it makes little sense and has a setting/premise that is a pastiche of William Gibson and the Terminator series. Meanwhile, he ignores a whole lot of really well done recent SF films; given his otherwise apparent highbrow bias, I’d think this guy would have LOVED Gattaca, and more recently while flawed Looper, Source Code, and In Time all had more depth and originality to their plots than the Matrix (let alone the tepid and nonsensical sequels) although none can match the visual spectacle of The Matrix ( or Star Wars. )
Found this via the FB memories feature, which is pretty cool.
On the PLOS blog (found via Medium) there was a really interesting post discussing the intersection of environmental conditions and genetics, and their impact on human evolution. The title may be either off-putting or funny to some, but it’s worth a read both on general interest or to those who have a particular interest in either human evolution or environmental science. Other than using the clinical term for the male genitalia, totally safe for work:
Plastics, tiny penises, and human evolution
An Italian study in 2012 found that men’s penises were growing smaller over time — two centimetres lost from grandfather to grandson in the twentieth century. Conservative radio bloviator Rush Limbaugh knew who to blame: ‘feminazis, the chickification, and everything else’ linked to feminism. Other commentators, a bit more scientific, pointed the finger at endocrine disrupting chemicals, such as pesticides and hormones fed to cattle, as likely culprits.
To anticipate how xenoestrogens or any other synthetic chemical that influences fertility might affect human evolution, it helps to consider niche construction theory.
It goes on from there. Go read it.
I loved this headline.
UK opposes international ban on developing ‘killer robots’
The article is interesting, but doesn’t live up to it.
Apropos of nothing, but awesome in a “I didn’t know that” sort of way:
This is nice. In 1899, Winston Churchill was 25, an aspiring politician, and the author of a couple of books. He was not, however, the most famous Winston Churchill around. That was the now largely forgotten, but at the time best-selling, American novelist… Winston Churchill. Aware of this, the British Winston Churchill wrote to his namesake as follows:
The original blog post is worth reading for the brief correspondence between the two.
Nightly auto-upgrades are great, except when they aren’t. In this case, going from app-misc/screen-4.0.3-r7 to app-misc/screen-4.2.1-r2 changed the default SCREENDIR from /run/screen to /tmp/screen. Normally wouldn’t care, but I had running screen sessions and couldn’t get in; oops!
Only realized about the SCREENDIR variable after I’d already downgraded back to 4.0.3-r7.