This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def getSongLength( | |
| artist: Artist, | |
| albumName: String, | |
| songName: String): Option[Int] = { | |
| for { | |
| album <- artist.getAlbum(albumName) | |
| song <- album.getSong(songName) | |
| } yield song.getLength | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ArrayListStockExchange implements StockExchange { | |
| private List<Trade> trades = new ArrayList<>(); | |
| @Override | |
| public void order(int ticket, int amount, int price, boolean buy) { | |
| trades.add(new Trade(ticket, amount, price, buy)); | |
| } | |
| @Override |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ListStockExchange : public StockExchange{ | |
| private: | |
| std::list<Trade *> * trades; | |
| public: | |
| ListStockExchange() { | |
| trades = new std::list<Trade *>(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Metrics | Java | C++ | |
|---|---|---|---|
| Iterations | 10 | 10 | |
| Min. iteration time [ms] | 4030.221 | 7890.256 | |
| Max. iteration time [ms] | 9432.062 | 7941.776 | |
| Avg. iteration time [ms] | 6251.026 | 7910.600 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Metrics | Java | C++ | C++ optimized | |
|---|---|---|---|---|
| Iterations | 10 | 10 | 10 | |
| Min. iteration time [ms] | 4030.221 | 7890.256 | 5136.895 | |
| Max. iteration time [ms] | 9432.062 | 7941.776 | 5166.630 | |
| Avg. iteration time [ms] | 6251.026 | 7910.600 | 5155.023 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Metrics | Java | C++ | C++ optimized | C++ off-heap | |
|---|---|---|---|---|---|
| Iterations | 10 | 10 | 10 | 10 | |
| Min. iteration time [ms] | 4030.221 | 7890.256 | 5136.895 | 6250.862 | |
| Max. iteration time [ms] | 9432.062 | 7941.776 | 5166.630 | 6286.141 | |
| Avg. iteration time [ms] | 6251.026 | 7910.600 | 5155.023 | 6267.842 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ListStockExchange : public StockExchange { | |
| private: | |
| std::list<Trade *> * trades; | |
| public: | |
| ListStockExchange() { | |
| trades = new std::list<Trade *>(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Metrics | Java | C++ | C++ optimized | C++ off-heap | C++ combined | |
|---|---|---|---|---|---|---|
| Iterations | 10 | 10 | 10 | 10 | 10 | |
| Min. iteration time [ms] | 4030.221 | 7890.256 | 5136.895 | 6250.862 | 2656.214 | |
| Max. iteration time [ms] | 9432.062 | 7941.776 | 5166.630 | 6286.141 | 2665.393 | |
| Avg. iteration time [ms] | 6251.026 | 7910.600 | 5155.023 | 6267.842 | 2662.243 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Iteration no. | Time[ms] | |
|---|---|---|
| 1 | 33656.406 | |
| 2 | 16100.784 | |
| 3 | 10734.691 | |
| 4 | 13656.410 | |
| 5 | 7297.651 | |
| 6 | 7732.481 | |
| 7 | 5081.496 | |
| 8 | 3020.896 | |
| 9 | 3126.210 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| object ScalarPuzzle extends App { | |
| implicit class TernaryOps(cond: => Boolean) { | |
| def ??(thenBlock: => Unit) = new { | |
| def ::(elseBlock: => Unit): Unit = | |
| if(cond) thenBlock else elseBlock | |
| } | |
| } | |
| (1 + 1 == 2) ?? println("True") :: println("False") |