-Поиск по дневнику

Поиск сообщений в rss_thedaily_wtf

 -Подписка по e-mail

 

 -Постоянные читатели

 -Статистика

Статистика LiveInternet.ru: показано количество хитов и посетителей
Создан: 06.04.2008
Записей:
Комментариев:
Написано: 0


CodeSOD: Polynomial Optimization

Четверг, 11 Декабря 2014 г. 14:00 + в цитатник

Marlschlag falsch&Schlingen

Rayer Ss co-worker exploded into his cube, beaming. Ive just optimized our processing loop. Ive gone from O(n2) to O(n)!

Thats amazing ! The processing loop in question was easily the most expensive part of the application, and Rayer had been spending too much time finding ways to squeeze a little performance out of it. How did you do it?

The original code looked something like this:

for(int i = 0; i < m; ++i) {
    for(int j = 0; j < n; ++j) {
    	process(target[i][j]); //this is really expensive
    }
}

It was a fairly standard nested loop operation.

Radar pulled the new version from source control to see his co-workers genius.

for(int i = 0; i < m * n; ++i) {
    process(*((target*)(&target) + i)); 
}

Radar complimented his co-worker on his understanding of C++ pointers, but had some negative things to say about his understanding of basic arithmetic.

[Advertisement] BuildMaster is more than just an automation tool: it brings together the people, process, and practices that allow teams to deliver software rapidly, reliably, and responsibly. And it's incredibly easy to get started; download now and use the built-in tutorials and wizards to get your builds and/or deploys automated!

http://thedailywtf.com/articles/polynomial-optimization

Метки:  

 

Добавить комментарий:
Текст комментария: смайлики

Проверка орфографии: (найти ошибки)

Прикрепить картинку:

 Переводить URL в ссылку
 Подписаться на комментарии
 Подписать картинку