Hi. Ich weiß dieses Thema findet sich im Netz rauf und runter... aber ich war irgendwie nicht dazu in der Lage eine Lösung trotz der vielen Anfragen zu finden, die mir diese schlechte Performance erklären. Ich habe mal die Performance meiner Methoden geloggt und auch den Durchschnitt dieser, wie lange sie gebraucht haben. nach 100 Ausführungen ist das hier das Ergebnis:
Mein Code dazu sieht aus wie folgt: (Ich denke zwei der Methoden werden reichen)
sorry, dass das jetzt so viel Code ist. Aber ich schnall einfach nicht, wieso das ganze so lange braucht. Was die Bilder angeht, die ich hochlade, diese sind im schlimmsten Falle 50kb groß (wirklich niemals größer und einige sind sogar nur 7kb), also eigentlich auch kein Grund für diese schlechte Performance.
Weiß jemand genaueres?
Code:
Method: callInsertActor took 0 sec. 361 millis:
-> average is: 0 sec. 599 millis: with 100 executions.
Method: callInsertGenre took 0 sec. 118 millis:
-> average is: 0 sec. 101 millis: with 100 executions.
Method: callInsertLanguage took 0 sec. 92 millis:
-> average is: 0 sec. 171 millis: with 100 executions.
Method: callInsertSubtitle took 0 sec. 41 millis:
-> average is: 0 sec. 344 millis: with 100 executions.
Dogma zur Datenbank hinzugefügt!
Method: callInsertMovie took 0 sec. 763 millis:
-> average is: 1 sec. 380 millis: with 100 executions.
Mein Code dazu sieht aus wie folgt: (Ich denke zwei der Methoden werden reichen)
Java:
private static SimpleJdbcCall insertMovie = null;
@LogTiming( methodName="callInsertMovie", average=true)
public static void callInsertMovie(final Movie movie) {
if (insertMovie == null) {
insertMovie = DBConnection.getInstance().getSimpleCall("insertmovie");
}
String oscars = "";
for(int x = 0; x < movie.getOscars().size(); x++){
oscars += movie.getOscars().get(x)+";b\\\n";
}
final File file = FileIO.getFile("Covers/"+movie.getID()+"."+movie.coverFileType);
MapSqlParameterSource in = new MapSqlParameterSource();
in.addValue("p_ean", movie.getEan());
in.addValue("p_title", movie.getTitle());
in.addValue("p_originaltitle", movie.getOriginalTitle());
in.addValue("p_regisseur", movie.getRegisseur());
in.addValue("p_runtime", movie.getRuntime().trim());
in.addValue("p_release", movie.getRelease());
in.addValue("p_rating", movie.getRating());
in.addValue("p_fsk", movie.getFSK());
in.addValue("p_oscars", oscars);
in.addValue("p_description", movie.getDescription());
in.addValue("p_cover", ImageBlobParser.getImageAsBlob(file));
in.addValue("p_covertype", movie.coverFileType.trim());
Map<String,Object> out = insertMovie.execute(in);
Object output = out.get("thisid");
if (output != null) {
int movieId = (int) output;
callInsertActor(movieId, movie.getActors());
callInsertGenre(movieId, movie.getGenres());
callInsertLanguage(movieId, movie.getLanguages());
callInsertSubtitle(movieId, movie.getSubtitles());
}
}
private static SimpleJdbcCall insertActor = null;
@LogTiming( methodName="callInsertActor", average=true )
private static void callInsertActor(int movieId, ArrayList<String> actors) {
if (insertActor == null) {
insertActor = DBConnection.getInstance().getSimpleCall("insertActor");
}
for (String actor: actors) {
String[] firstAndLast = StringOps.splitFirstAndLast(actor);
if (firstAndLast != null) {
MapSqlParameterSource in = new MapSqlParameterSource();
in.addValue("p_firstname", firstAndLast[0].trim());
in.addValue("p_lastname", firstAndLast[1].trim());
in.addValue("p_movieid", movieId);
insertActor.execute(in);
}
}
}
sorry, dass das jetzt so viel Code ist. Aber ich schnall einfach nicht, wieso das ganze so lange braucht. Was die Bilder angeht, die ich hochlade, diese sind im schlimmsten Falle 50kb groß (wirklich niemals größer und einige sind sogar nur 7kb), also eigentlich auch kein Grund für diese schlechte Performance.
Weiß jemand genaueres?