Skip to content

Instantly share code, notes, and snippets.

View bandrzejczak's full-sized avatar

Bartek Andrzejczak bandrzejczak

View GitHub Profile
class ListStockExchange : public StockExchange {
private:
std::list<Trade *> * trades;
public:
ListStockExchange() {
trades = new std::list<Trade *>();
}
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
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
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
class ListStockExchange : public StockExchange{
private:
std::list<Trade *> * trades;
public:
ListStockExchange() {
trades = new std::list<Trade *>();
}
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
def getSongLength(
artist: Artist,
albumName: String,
songName: String): Option[Int] = {
for {
album <- artist.getAlbum(albumName)
song <- album.getSong(songName)
} yield song.getLength
}
Integer getSongLength(Artist artist, String albumName, String songName){
return artist
.getAlbum(albumName)
.map(a -> a.getSong(songName))
.map(Song::getTime)
.orElseThrow(() -> new NoSuchSongException(artist, albumName, songName));
}
Integer getSongLength(
Artist artist,
String albumName,
String songName) {
Album album = artist.getAlbum(albumName);
if (album != null) {
Song song = album.getSong(songName);
if (song != null) {
return song.getLength();
def plotSquares(n, plotter):
for x in range(0, n + 1):
plotter.plot(Point(x, x * x))