This file contains 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 Test { | |
static int objectCount = 0; | |
public static int getObjectCount() { | |
return objectCount; | |
} | |
public Test() { | |
objectCount++; |
This file contains 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 ObjectArrayParameterByValue { | |
public static void main(String[] args) { | |
String[] data = { "Foo", "Bar" }; | |
System.out.println(data[0]); | |
} | |
public void changeArray(String[] data) { | |
data[0] = "Changed"; |
This file contains 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
Otras iniciativas: | |
Neuralink: https://neuralink.com/ | |
Boring company: https://www.boringcompany.com/ | |
Hyperloop: https://es.wikipedia.org/wiki/Hyperloop | |
OpenAI: https://es.wikipedia.org/wiki/OpenAI | |
Elon Musk fumado | |
https://gizmodo.com/elon-musk-smoking-joe-rogans-weed-somehow-ended-up-cost-1839116211 | |
Financial rounds Tesla: 20.4B |
This file contains 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
import java.util.Collection; | |
import java.util.HashMap; | |
import java.util.Map; | |
import java.util.stream.Collectors; | |
public class MapViews { | |
public static void main(String[] args) { | |
mapChangeModifiesValuesSet(); | |
mapChangeModifiesKeysSet(); |
This file contains 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
//BikeySet<Avenger, Film> avengerFilms = new TableBikeySet<>(); | |
BikeySet<String, String> avengerFilms = new TableBikeySet<>(); | |
avengerFilms.add("Hulk", "The Avengers"); | |
avengerFilms.add("Iron Man", "The Avengers"); | |
avengerFilms.add("Thor", "Avengers: Age of Ultron"); | |
avengerFilms.add("Thor", "Thor: Ragnarok"); | |
avengerFilms.add("Captain America", "Avengers: Infinity War"); | |
.... | |
if (avengerFilms.contains("Iron Man", "Black Panther")) { |
This file contains 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
//Given the stock of some products and stores | |
//BikeyMap<Product, Store, Stock> stock = new TableBikeyMap<>(); | |
BikeyMap<String, String, Integer> stock = new TableBikeyMap<>(); | |
stock.put("shirt-ref-123", "store-76", 10); | |
stock.put("pants-ref-456", "store-12", 24); | |
... | |
stock.put("tie-ref-789", "store-23", 2); | |
//Get the stock of a product/store | |
Integer inStock = stock.get("shirt-ref-1234", "store-45"); |
This file contains 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
MemoryMXBean mbean = ManagementFactory.getMemoryMXBean(); | |
MemoryUsage beforeHeapMemoryUsage = mbean.getHeapMemoryUsage(); | |
Object instance = codeThatCreatesComplexDataStructure(); | |
MemoryUsage afterHeapMemoryUsage = mbean.getHeapMemoryUsage(); | |
long consumed = afterHeapMemoryUsage.getUsed() - | |
beforeHeapMemoryUsage.getUsed(); | |
System.out.println("Total consumed Memory:" + consumed); |
This file contains 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
methodThatDoesThings(); | |
MemoryHistogram diff = Histogramer.getDiff(() -> { | |
return methodThatDoesThings(); | |
}); | |
System.out.println(diff); | |
This file contains 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
MemoryHistogram filterd = diff.filter("Object[]", "java.util.HashMap*", | |
ArrayList.class, Pattern.compile(".*Hibernate.*")); | |
This file contains 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
MemoryHistogram diff = Histogramer.getDiff(() -> { | |
HashMap<Integer, String> map = new HashMap<>(); | |
for (int i = 0; i < 10000; i++) { | |
map.put(i, "" + i); | |
} | |
return new ArrayList<>(map.values()); | |
}); | |
System.out.println(diff); |
NewerOlder