|
Ornedan posted:Are these some optimisation flags Eclipse enables by default that could cause the difference? Eclipse has its own compiler actually. They do that because they can do incremental compilation, some limited hot-swapping during debug, and it allows running code that has partial errors (sometimes). That being said profiling Java code is a surprisingly delicate problem because, as you have already seen, the JVM under the covers is doing all sorts of just in time compilation caching and optimizations. Generally I would recommend that you use something like the Java Microbenchmarking Harness and also that you put the code into a loop, let it execute a few times, and then run it for a few thousand iterations and aggregate the results. That will let the JVM have time to warm up and do its runtime optimizations so your numbers are more likely to be honest to real world performance. If you are feeling really bold you could also look at using some of the new ahead of time compilation tools in JDK 17+ or GraalVM to pre-compile down to native code. This should eliminate the JIT warmup speeds if you have stuff that runs only rarely and only one or two times per lifetime of the application. Objective Action fucked around with this message at 16:14 on Jul 9, 2023 |
# ? Jul 9, 2023 16:11 |
|
|
# ? May 4, 2024 16:16 |
|
Ornedan posted:Are these some optimisation flags Eclipse enables by default that could cause the difference? For microbenchmarks like this, you may wish to force HotSpot to always use the server compiler, under the assumption that your code in a real setting would trigger the optimizing compiler threshold anyway (which, by the sound of things, is indeed plausible). There's a HotSpot flag that will let you disable tiered compilation, and another that will set the C2 hot code threshold low enough to be triggered early. e: beaten massively, this is what I get for leaving an old tab open Objective Action posted:Generally I would recommend that you use something like the Java Microbenchmarking Harness and also that you put the code into a loop, let it execute a few times, and then run it for a few thousand iterations and aggregate the results. That will let the JVM have time to warm up and do its runtime optimizations so your numbers are more likely to be honest to real world performance. Dijkstracula fucked around with this message at 15:35 on Jul 10, 2023 |
# ? Jul 10, 2023 15:27 |
|
edit: poooop
Lamech fucked around with this message at 02:18 on Jul 11, 2023 |
# ? Jul 11, 2023 01:58 |
|
Well step one: Java is not JavaScript
|
# ? Jul 11, 2023 02:11 |
|
doh wrong one see ya
|
# ? Jul 11, 2023 02:18 |
|
Can't really blame people for making the mistake given JavaScript specifically was chosen as the name to make people conflate the two.
|
# ? Jul 11, 2023 02:20 |
Still pisses me off. What a dumb rear end in a top hat move
|
|
# ? Jul 11, 2023 03:12 |
|
Java code:
pre:Benchmark Mode Cnt Score Error Units ReverseBitsBenchmark.testBithack3 avgt 25 1.417 ± 0.016 ns/op ReverseBitsBenchmark.testBithack4 avgt 25 0.889 ± 0.010 ns/op ReverseBitsBenchmark.testLookup avgt 25 0.721 ± 0.009 ns/op ReverseBitsBenchmark.testNybbles avgt 25 1.073 ± 0.026 ns/op ReverseBitsBenchmark.testStdlib avgt 25 1.987 ± 0.107 ns/op ReverseBitsBenchmark.testSwaps avgt 25 1.874 ± 0.031 ns/op I did poke the javac vs Eclipse thing a bit further. Moving each of the test loops into a separate method made javac output as fast as Eclipse output. So I'm guessing the javac-generated bytecode does something dumb with the 2nd and later loops.
|
# ? Jul 11, 2023 10:31 |
|
Nice work! Always nice to see people doing fun stuff and reporting on it in the thread.
|
# ? Jul 11, 2023 15:02 |
|
So I am completely stumped with what I'm doing wrong with my Builder pattern. I've been staring at it for a week and combing SO hasn't found me any explanation on why it's occuring. I'm using Apache Commons for parsing a CSV file and creating a map of maps that looks like this Map<String, Map<Enum, Interface>>. The problem occuring is that after the map is populated, when I check the objects in the map; they're all pointing to the same object.code:
Java code:
Java code:
I haven't updated my repo recently, but if it would help I can cut a branch with this work in it and if that would help. Let me know if there's anything else that would help with figuring this out. Also, critique on code and design is welcomed. This is early in my personal project so if I'm doing something ugly, let me know so I can work it. Not looking for you to solve it, just call it out and I'll gladly spend the time to learn how to do it. Thank you. LostMy2010Accnt fucked around with this message at 12:37 on Sep 13, 2023 |
# ? Sep 13, 2023 12:28 |
|
On my phone but from a glance it looks like hereJava code:
you're assigning the elementStats Map to every entry in teamStats, which is why the printed output is the same printed object's position in memory. I might be misunderstanding but could you either comment or pseudocode what you're trying to do there and also what you expect it to print instead of what you showed in your post?
|
# ? Sep 13, 2023 13:02 |
|
Tesseraction posted:On my phone but from a glance it looks like here Yeah probably just needs to move the elementStats = new… inside the records loop so each team has its own elementStats.
|
# ? Sep 13, 2023 14:52 |
|
Tesseraction posted:On my phone but from a glance it looks like here Thank you for looking into it, I'll try to explain better what I'm doing. So I'm trying to parse a CSV file and then from it create a Map that consists of a key for the team name and then a value of another map. In the inner map I want to use an enum to classify the type or name of the object and then the value is the object itself. for the loop here's what I'm trying to do: code:
Again, apologies if I'm not describing it well; I'm terrible with programing venacular, it's a weak spot of mine that I'm really tryin to improve upon.
|
# ? Sep 13, 2023 15:37 |
|
VegasGoat posted:Yeah probably just needs to move the elementStats = new… inside the records loop so each team has its own elementStats. Thank you. I'll give that a try and report back what happens.
|
# ? Sep 13, 2023 15:38 |
|
Okay looking into this a little closer, first thing I'm gonna pull up isn't the solution, butJava code:
Java code:
Java code:
As for the rest... if you could upload a sanitised version of your code/CSV file to your source repo it would help me at the very least dissect where the issue is. At the very least it'll let me run through the debugger to see where things start going south.
|
# ? Sep 13, 2023 21:25 |
|
Tesseraction posted:Okay looking into this a little closer, first thing I'm gonna pull up isn't the solution, but Thank you. I'm having issues with my project because I'm trying to learn Maven along the way so it's going to take me a little to get it going. I'll post back when I get it it squared away.
|
# ? Sep 14, 2023 11:14 |
|
Tesseraction posted:... Okay I made the correction to my builder class and updated my branch with the changes. https://github.com/sDriskell/HockeyStats/tree/build_csv_consumer There's a csv file inside HockeyStatVisualizer that I'm using. It's only 32 rows but does have about 71 columns. Currently only working with the first 10 columns. Still having issues with my maven pom file; it's new to me but I've not had luck building it, just importing dependencies for the project. Also working on why log4j2 isn't logging either; I think it might have something to do with where I have it in the project directory. If any of these are causing you issues, then don't sweat looking into this. Appreciate it, thanks.
|
# ? Sep 15, 2023 11:05 |
|
LostMy2010Accnt posted:Still having issues with my maven pom file; it's new to me but I've not had luck building it, just importing dependencies for the project. Also working on why log4j2 isn't logging either; I think it might have something to do with where I have it in the project directory. If any of these are causing you issues, then don't sweat looking into this. Appreciate it, thanks. Your log4j2.xml should be under src/main/resources. What errors are you seeing with the pom?
|
# ? Sep 15, 2023 13:46 |
|
Okay I've download your git repo and it seems rather different from the code you were asking a question about. I don't see a Map anywhere here? This code seems to work fine?
|
# ? Sep 15, 2023 17:32 |
|
LostMy2010Accnt posted:Still having issues with my maven pom file; it's new to me but I've not had luck building it, just importing dependencies for the project. Also working on why log4j2 isn't logging either; I think it might have something to do with where I have it in the project directory. If any of these are causing you issues, then don't sweat looking into this. Appreciate it, thanks. I know it’s easy to try and do a lot at once, but I’d highly recommend trying to change one thing at a time so you can more easily identify where any problems are. I’m not a superdev by any means but that has been really helpful for my debugging.
|
# ? Sep 15, 2023 21:37 |
|
Pedestrian Xing posted:Your log4j2.xml should be under src/main/resources. What errors are you seeing with the pom? Ah I just had in source, thank you for catching that. Not seeing errors with pom more that: 1) I'm just trying to learn how to use it; 2) Eclipse is acting really odd whenever I try to modify it at times (Weird spacing, freezes, etc.). Tesseraction posted:Okay I've download your git repo and it seems rather different from the code you were asking a question about. I don't see a Map anywhere here? This code seems to work fine? Sorry it should be the build_csv_consumer branch that I've commited the current work I have. Please don't feel obligated to go too deep in this. I think this is really more of a byproduct of me trying to make multiple changes at a single time with this project. I hate wasting time so don't stress over this one. franks posted:I know it’s easy to try and do a lot at once, but I’d highly recommend trying to change one thing at a time so you can more easily identify where any problems are. I’m not a superdev by any means but that has been really helpful for my debugging. Yeah, this was a learning lesson in that this week. Thank you everyone for jumping in and helping. I think my lesson today is to not make so many changes concurrently so I'll take the L on that.
|
# ? Sep 16, 2023 10:13 |
|
Looking at the code (your Maven config seemed correct FWIW) it's doing what you want it to, just with the issue of you assigning the full Map<EStatTypes, IStats> elementStats to every Team entry in the Map<String, Map<EStatTypes, IStats>> teamStats. Let's pick three teams, I'll take the first three in your CSV, the Anaheim Ducks, the Arizona Coyotes, and the Boston Bruins. As it goes over these three CSVRecord team elements: elementStats creates a new entry for the Anaheim Ducks, with the stats you specified, effectively a key,value of ["Anaheim Ducks", StandardTeamStatsObj@1] It then adds this to teamStats as ["Anaheim Ducks", [ ["Anaheim Ducks", StandardTeamStatsObj@1] ] ] next it adds an entry of ["Arizona Coyotes",StandardTeamStatsObj@2] to elementStats, this now makes it [ ["Anaheim Ducks", StandardStatsObj@1] , ["Arizona Coyotes",StandardStatsObj@2] ] now you're adding that to teamStats as ["Arizona Coyotes", [ ["Anaheim Ducks", StandardStatsObj@1] , ["Arizona Coyotes",StandardStatsObj@2] ] ] And because Java passes by reference, the entry for Anaheim Ducks has now changed to ["Anaheim Ducks", [ ["Anaheim Ducks", StandardStatsObj@1] , ["Arizona Coyotes",StandardStatsObj@2] ] ] So lastly the Boston Bruins will be added to teamStats as ["Boston Bruins", [ ["Anaheim Ducks", StandardStatsObj@1] , ["Arizona Coyotes",StandardStatsObj@2] , ["Boston Bruins",StandardStatsObj@3] ] ] I hope this clarifies why your code isn't doing what you're expecting? I guess we can simplify this a bit: for the three loops, to save a bit of time I'm shortening the teams to AD, AC and BB: loop 1 elementStats adds ["AD",STS@1] elementStats is an object we will call object ES@1 loop 1 teamStats adds ["AD",ES@1] loop 2 elementStats adds ["AC",STS@2] elementStats is the same object, ES@1 loop 2 teamStats adds ["AC", ES@1] loop 3 elementStats adds ["BB",STS@3] elementStats is the same object, ES@1 loop 2 teamStats adds ["BB", ES@1] Does that make sense?
|
# ? Sep 16, 2023 12:59 |
|
LostMy2010Accnt posted:Ah I just had in source, thank you for catching that. Not seeing errors with pom more that: 1) I'm just trying to learn how to use it; 2) Eclipse is acting really odd whenever I try to modify it at times (Weird spacing, freezes, etc.). Turn off any kind of auto-import or sync your IDE might be doing on pom.xml modification and trigger it manually when you make a change.
|
# ? Sep 17, 2023 00:21 |
|
I have a problem deciding what is the least crap way of implementing choicebox values in javafx. Depending on user selections and choiceboxes, I need to have a variable_id (for API calls) associated with the choice, or a LineChart.class for example, so I know what kind of XYChart the user wants to draw. How would you store the choices? Enums? Classes? Something else? Enums work ok'ish with strings, like this: Java code:
This seems to work: Java code:
Java code:
This thing is a 4 man course project, still on prototype stage, so I can try out all kinds of stuff. Ihmemies fucked around with this message at 06:14 on Sep 17, 2023 |
# ? Sep 17, 2023 06:07 |
|
Ihmemies posted:I have a problem deciding what is the least crap way of implementing choicebox values in javafx. Depending on user selections and choiceboxes, I need to have a variable_id (for API calls) associated with the choice, or a LineChart.class for example, so I know what kind of XYChart the user wants to draw. I don't understand why you need to store a class here? Instantiating from a Class<?> value is not really done except when you're doing some really nasty reflection/bytecode manipulation fuckery. Personally I would go with a similar way that in my brain looks cleaner (completely my preferences/biases though) Java code:
EDIT: Oh, JavaFX. hmm.
|
# ? Sep 17, 2023 06:31 |
|
Well that seems to work too. We are using 17 so I guess I can research sealed classes too. Thanks
|
# ? Sep 17, 2023 07:08 |
|
Tesseraction posted:Looking at the code (your Maven config seemed correct FWIW) it's doing what you want it to, just with the issue of you assigning the full Map<EStatTypes, IStats> elementStats to every Team entry in the Map<String, Map<EStatTypes, IStats>> teamStats. poo poo. Okay I see what you're saying. Thank you for taking the time to look into this and explaining what I was missing. Much appreciated! Pedestrian Xing posted:Turn off any kind of auto-import or sync your IDE might be doing on pom.xml modification and trigger it manually when you make a change. Oh that makes sense. Thank you.
|
# ? Sep 17, 2023 10:21 |
|
We're doing a desktop app for course, because web abbs were explicitly forbidden. We ended up using javafx because that's what a few guys have used earlier. Is there some "easy" way to specify the line/area colors? I looked at assigning an ID to each data series (line) depending on datatype, and then applying the color for that id with CSS. Like nuclear = YELLOW, wind = GREEN, hydro = BLUE etc. But no, this poo poo rear end piece of garbage apparently gives data series id's automatically from 0..n, based on the add order to chart. So I'd have to make some kind of hell construct to figure out the id of each added series... etc. I don't even want to think about it. The chart can have any amount of series depending on datatype. Each datatype should have a specific color always... Who ***** thought that it is ***** good idea to label the series automatically with incrementing id, which depends on add order... Already thinking about implementing a webview inside the javafx app. Ihmemies fucked around with this message at 11:31 on Oct 20, 2023 |
# ? Oct 20, 2023 11:28 |
|
Could you extend the Chart.Data object to include its type of energy and use that to determine its colour? Sorry if I'm misremembering JavaFX, I haven't touched it in 15 years.
|
# ? Oct 20, 2023 11:56 |
|
CPColin posted:I like that future() function that it calls, which does a bounds check, then performs an array operation that does the same bounds check, except correctly (it should be >=, not >). I am slightly terrified that I just decided to interview at a place using Vert.x and this is apparently the most recent reference to using it here, as well as hardly any mention of it anywhere online as a hardened spring guy who has enough experience with web flux to make it not explode, why do I want vert.x instead of spring + web flux for reactive apps? what am I gaining with vert.x that makes up for losing everything spring gives me? (the answer will be "because their management pays you to write it using vert.x" but I'd like to know if there's an actual good reason)
|
# ? Feb 1, 2024 00:43 |
|
Tempora Mutantur posted:I am slightly terrified that I just decided to interview at a place using Vert.x and this is apparently the most recent reference to using it here, as well as hardly any mention of it anywhere online IIRC Vert.x is a much smaller microservices framework with some performance gains over Spring/Spring Boot. OTOH it's not anywhere near as popular with all the issues that implies. I haven't worked with it myself though.
|
# ? Feb 1, 2024 03:17 |
|
Tempora Mutantur posted:because their management pays you to write it using vert.x and that should be enough.
|
# ? Feb 1, 2024 04:19 |
|
Tempora Mutantur posted:(the answer will be "because their management pays you to write it using vert.x" but I'd like to know if there's an actual good reason) Seriously dude, you think working at any of the FAANG companies will get your relevant experience in technology X, only to find that internally they use some janky custom built poo poo that then spawned into the frameworks you love.
|
# ? Feb 1, 2024 19:46 |
|
CPColin posted:I like that future() function that it calls, which does a bounds check, then performs an array operation that does the same bounds check, except correctly (it should be >=, not >). I went back and looked, by the way, and somebody did come along and fix it so it's >= and not >, but there's still a question of why they bother to throw IndexOutOfBoundsException explicitly when ArrayIndexOutOfBoundsException extends that class anyway. I guess maybe they're trying to hide the detail that an array is involved?
|
# ? Feb 1, 2024 23:21 |
|
We use Vertx at work. I’m not an expert but I don’t like the resulting code. Lots of callback methods to get the async behavior. Tends to end up with massive methods with stupid level of indentation that are not trivial to refactor. Also difficult in practice to properly catch errors if they are thrown in the callback.
|
# ? Feb 3, 2024 15:51 |
Not being a java dev or even knowing java I've been given 2k lines of uncommented code that I did not write to own. It lives in a SaaS solution. The method that's called is passed multiple SQL statements for tables that do not exist locally as well as a flat file of employee information. I do not have a development workspace where I can setup temp tables for testing nor would I really be able to without being able to setup a mini SaaS product. Pushing code up to the SaaS solution and a test run after any changes takes about 4 hours. Having never used Eclipse or any other java IDE I have no idea how I can step through this code to see what methods are actually being used. There are methods in different classes with the same name, some are called, some are literally example code the vendor threw in there from their KBs which I know are not used. I need to get familiarity with Eclipse before I start to modify this, and using "Control + H" on methods is making my eyes bleed. I know when compiling the Jar if I delete the wrong method or class it'll let me know, but I want to approach it in the inverse so I can get these 2k lines of code down to a more manageable 800 or so. I guess what I'm looking for is a good Eclipse primer and the OP is like 14 years old.
|
|
# ? Feb 7, 2024 13:54 |
|
You have a while to go until it becomes an IDE question. You need to find out what do you need to do to run and debug the code that you have to modify. Which in turn requires a bit more knowledge of the product itself. Then you can come and ask "how do I do X in Eclipse" (or whatever other IDE. I'm sure intellij will be suggested, not that it will make a difference).
|
# ? Feb 7, 2024 14:50 |
What if, due to not having local class dependencies, I could never effectively get an actual local run in the IDE? Seems like I'll need to cut and compile and test I was hoping I could say call com.vendor.foo.impla(bar) and just run through the classes that enumerates through. Not an actual test case, just sorta how problems will display if I axe the wrong method or class. An unused code plugin gave nada. com.vendor.foo is not a public library. I'll hunt for some docs but I can't even find documentation to determine environmental variables or subdomains where the code is running to solve for hardcoded dev vs prod variables (lmao it's worse than that, hard coded domains etc in code). Submarine Sandpaper fucked around with this message at 15:53 on Feb 7, 2024 |
|
# ? Feb 7, 2024 15:48 |
|
Submarine Sandpaper posted:Not being a java dev or even knowing java I've been given 2k lines of uncommented code that I did not write to own. It lives in a SaaS solution. I am very sorry, but what you are describing is a horrible nightmare of programming that I would never wish on another developer. At that point I wouldn't even try to salvage it into "working". I would try to refactor it into a couple of objectives mapped into classes and several runtimes into routines to accomplish a certain thing? Eclipse is just a thing to vomit boilerplate code into your project. It isn't necessary to do what you want. Please just break it apart into more pieces with more concrete objectives.
|
# ? Apr 1, 2024 20:58 |
|
|
# ? May 4, 2024 16:16 |
What's a good way of identifying 3rd party Java dependencies that are no longer actively maintained? It's pretty straightforward with maven to find out which dependencies are out of date, meaning there is a newer version available. What about for the case when you are on the latest version of a dependency, but there hasn't been a new version in a while and the project is no longer maintained?
|
|
# ? Apr 3, 2024 22:06 |