cleanup
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
|
||||
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd" version="2.1">
|
||||
|
||||
<!-- JDO tutorial "unit" -->
|
||||
<persistence-unit name="Tutorial">
|
||||
<exclude-unlisted-classes/>
|
||||
<properties>
|
||||
<property name="javax.jdo.PersistenceManagerFactoryClass" value="org.datanucleus.api.jdo.JDOPersistenceManagerFactory"/>
|
||||
<property name="javax.jdo.option.ConnectionURL" value="jdbc:h2:mem:mypersistence"/>
|
||||
<property name="javax.jdo.option.ConnectionDriverName" value="org.h2.Driver"/>
|
||||
<property name="javax.jdo.option.ConnectionUserName" value="sa"/>
|
||||
<property name="javax.jdo.option.ConnectionPassword" value=""/>
|
||||
<property name="datanucleus.schema.autoCreateAll" value="true"/>
|
||||
</properties>
|
||||
</persistence-unit>
|
||||
</persistence>
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
1|IND|India
|
||||
2|MY|Malaysia
|
||||
3|AU|Australia
|
||||
|
@@ -1,6 +0,0 @@
|
||||
dataSourceClassName=//TBD
|
||||
dataSource.user=//TBD
|
||||
dataSource.password=//TBD
|
||||
dataSource.databaseName=//TBD
|
||||
dataSource.portNumber=//TBD
|
||||
dataSource.serverName=//TBD
|
||||
Binary file not shown.
@@ -1,15 +0,0 @@
|
||||
var first = {
|
||||
name: "Whiskey",
|
||||
age: 5
|
||||
};
|
||||
|
||||
var second = {
|
||||
volume: 100
|
||||
};
|
||||
|
||||
Object.bindProperties(first, second);
|
||||
|
||||
print(first.volume);
|
||||
|
||||
second.volume = 1000;
|
||||
print(first.volume);
|
||||
@@ -1 +0,0 @@
|
||||
print(__FILE__, __LINE__, __DIR__);
|
||||
@@ -1,19 +0,0 @@
|
||||
var math = {
|
||||
increment: function (num) {
|
||||
return ++num;
|
||||
},
|
||||
|
||||
failFunc: function () {
|
||||
try {
|
||||
throw "BOOM";
|
||||
} catch (e if typeof e === 'string') {
|
||||
print("String thrown: " + e);
|
||||
}
|
||||
catch (e) {
|
||||
print("this shouldn't happen!");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
math;
|
||||
@@ -1,11 +0,0 @@
|
||||
var demo = {
|
||||
__noSuchProperty__: function (propName) {
|
||||
print("Accessed non-existing property: " + propName);
|
||||
},
|
||||
|
||||
__noSuchMethod__: function (methodName) {
|
||||
print("Invoked non-existing method: " + methodName);
|
||||
}
|
||||
};
|
||||
|
||||
demo;
|
||||
@@ -1 +0,0 @@
|
||||
function increment(num) ++num;
|
||||
@@ -1,2 +0,0 @@
|
||||
print(" hello world".trimLeft());
|
||||
print("hello world ".trimRight());
|
||||
@@ -1,9 +0,0 @@
|
||||
function arrays(arr) {
|
||||
|
||||
var javaIntArray = Java.to(arr, "int[]");
|
||||
print(javaIntArray[0]);
|
||||
print(javaIntArray[1]);
|
||||
print(javaIntArray[2]);
|
||||
}
|
||||
|
||||
arrays([100, "1654", true]);
|
||||
@@ -1,6 +0,0 @@
|
||||
log4j.rootLogger=DEBUG, A1
|
||||
|
||||
log4j.appender.A1=org.apache.log4j.ConsoleAppender
|
||||
|
||||
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
|
||||
@@ -1,9 +0,0 @@
|
||||
|
||||
# Root logger
|
||||
log4j.rootLogger=INFO, file, stdout
|
||||
|
||||
# Write to console
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.Target=System.out
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
|
||||
Binary file not shown.
@@ -1,2 +0,0 @@
|
||||
line 1
|
||||
a second line
|
||||
+26
-22
@@ -1,27 +1,31 @@
|
||||
package com.baeldung.java.concurrentmap;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ConcurrentMapPerformanceManualTest {
|
||||
|
||||
@Test
|
||||
public void givenMaps_whenGetPut500KTimes_thenConcurrentMapFaster() throws Exception {
|
||||
Map<String, Object> hashtable = new Hashtable<>();
|
||||
Map<String, Object> synchronizedHashMap = Collections.synchronizedMap(new HashMap<>());
|
||||
Map<String, Object> concurrentHashMap = new ConcurrentHashMap<>();
|
||||
final Map<String, Object> hashtable = new Hashtable<>();
|
||||
final Map<String, Object> synchronizedHashMap = Collections.synchronizedMap(new HashMap<>());
|
||||
final Map<String, Object> concurrentHashMap = new ConcurrentHashMap<>();
|
||||
|
||||
long hashtableAvgRuntime = timeElapseForGetPut(hashtable);
|
||||
long syncHashMapAvgRuntime = timeElapseForGetPut(synchronizedHashMap);
|
||||
long concurrentHashMapAvgRuntime = timeElapseForGetPut(concurrentHashMap);
|
||||
final long hashtableAvgRuntime = timeElapseForGetPut(hashtable);
|
||||
final long syncHashMapAvgRuntime = timeElapseForGetPut(synchronizedHashMap);
|
||||
final long concurrentHashMapAvgRuntime = timeElapseForGetPut(concurrentHashMap);
|
||||
|
||||
System.out.println(String.format("Hashtable: %s, syncHashMap: %s, ConcurrentHashMap: %s", hashtableAvgRuntime, syncHashMapAvgRuntime, concurrentHashMapAvgRuntime));
|
||||
|
||||
@@ -31,13 +35,13 @@ public class ConcurrentMapPerformanceManualTest {
|
||||
}
|
||||
|
||||
private long timeElapseForGetPut(Map<String, Object> map) throws InterruptedException {
|
||||
ExecutorService executorService = Executors.newFixedThreadPool(4);
|
||||
long startTime = System.nanoTime();
|
||||
final ExecutorService executorService = Executors.newFixedThreadPool(4);
|
||||
final long startTime = System.nanoTime();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
executorService.execute(() -> {
|
||||
for (int j = 0; j < 500_000; j++) {
|
||||
int value = ThreadLocalRandom.current().nextInt(10000);
|
||||
String key = String.valueOf(value);
|
||||
final int value = ThreadLocalRandom.current().nextInt(10000);
|
||||
final String key = String.valueOf(value);
|
||||
map.put(key, value);
|
||||
map.get(key);
|
||||
}
|
||||
@@ -56,11 +60,11 @@ public class ConcurrentMapPerformanceManualTest {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
int executeTimes = 5000;
|
||||
final int executeTimes = 5000;
|
||||
|
||||
Map<SameHash, Integer> mapOfSameHash = new ConcurrentHashMap<>();
|
||||
final Map<SameHash, Integer> mapOfSameHash = new ConcurrentHashMap<>();
|
||||
ExecutorService executorService = Executors.newFixedThreadPool(2);
|
||||
long sameHashStartTime = System.currentTimeMillis();
|
||||
final long sameHashStartTime = System.currentTimeMillis();
|
||||
for (int i = 0; i < 2; i++) {
|
||||
executorService.execute(() -> {
|
||||
for (int j = 0; j < executeTimes; j++) {
|
||||
@@ -71,10 +75,10 @@ public class ConcurrentMapPerformanceManualTest {
|
||||
executorService.shutdown();
|
||||
executorService.awaitTermination(5, TimeUnit.SECONDS);
|
||||
|
||||
long mapOfSameHashDuration = System.currentTimeMillis() - sameHashStartTime;
|
||||
Map<Object, Integer> mapOfDefaultHash = new ConcurrentHashMap<>();
|
||||
final long mapOfSameHashDuration = System.currentTimeMillis() - sameHashStartTime;
|
||||
final Map<Object, Integer> mapOfDefaultHash = new ConcurrentHashMap<>();
|
||||
executorService = Executors.newFixedThreadPool(2);
|
||||
long defaultHashStartTime = System.currentTimeMillis();
|
||||
final long defaultHashStartTime = System.currentTimeMillis();
|
||||
for (int i = 0; i < 2; i++) {
|
||||
executorService.execute(() -> {
|
||||
for (int j = 0; j < executeTimes; j++) {
|
||||
@@ -85,11 +89,11 @@ public class ConcurrentMapPerformanceManualTest {
|
||||
executorService.shutdown();
|
||||
executorService.awaitTermination(5, TimeUnit.SECONDS);
|
||||
|
||||
long mapOfDefaultHashDuration = System.currentTimeMillis() - defaultHashStartTime;
|
||||
final long mapOfDefaultHashDuration = System.currentTimeMillis() - defaultHashStartTime;
|
||||
assertEquals(executeTimes * 2, mapOfDefaultHash.size());
|
||||
assertEquals(executeTimes * 2, mapOfSameHash.size());
|
||||
System.out.println(String.format("same-hash: %s, default-hash: %s", mapOfSameHashDuration, mapOfDefaultHashDuration));
|
||||
assertTrue("same hashCode() should greatly degrade performance", mapOfSameHashDuration > mapOfDefaultHashDuration * 10);
|
||||
assertTrue("same hashCode() should greatly degrade performance", mapOfSameHashDuration > (mapOfDefaultHashDuration * 10));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
# this is sample property file for PropertiesLoaderTest configuration needs
|
||||
! this is also a comment
|
||||
sampleConfEntry = sample String value
|
||||
colonSeparatedEntry : colon separated entry value
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1 +0,0 @@
|
||||
Test of JNDI on file.
|
||||
@@ -1 +0,0 @@
|
||||
Hello world
|
||||
@@ -1 +0,0 @@
|
||||
Hello world !
|
||||
@@ -1 +0,0 @@
|
||||
Hello world
|
||||
@@ -1 +0,0 @@
|
||||
Hello world 1
|
||||
@@ -1 +0,0 @@
|
||||
2,3 4
|
||||
@@ -1 +0,0 @@
|
||||
Hello 1
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
青空
|
||||
@@ -1,2 +0,0 @@
|
||||
Hello world
|
||||
Test line
|
||||
@@ -1 +0,0 @@
|
||||
John,Adam-Tom
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user