How do I read Intellij coverage report? - intellij-idea

I am doing unit tests and I recently find out about the coverage test feature in IntelliJ.
Things are pretty clear except when generating the coverage report I don't understand why in the more detailed view of the report it shows the $$anonfun$x (where x is a number) suffix.
I'll show you an example:
Class Method, % Line, %
DataContent 100% (5/ 5) 94.7% (18/ 19)
DataContent$$anonfun$1 0% (0/ 1) 0% (0/ 1)
DataContent$$anonfun$10 100% (1/ 1) 100% (1/ 1)
DataContent$$anonfun$11 100% (1/ 1) 100% (1/ 1)
DataContent$$anonfun$12 100% (2/ 2) 100% (4/ 4)
DataContent$$anonfun$12$$anonfun$13 100% (1/ 1) 100% (1/ 1)
DataContent$$anonfun$14 100% (1/ 1) 100% (1/ 1)
DataContent$$anonfun$14$$anonfun$apply$5 100% (1/ 1) 100% (1/ 1)
DataContent$$anonfun$14$$anonfun$apply$6 100% (2/ 2) 100% (4/ 4)
DataContent$$anonfun$14$$anonfun$apply$6$$anonfun$15 100% (1/ 1) 100% (1/ 1)
DataContent$$anonfun$9 100% (1/ 1) 100% (1/ 1)
DataContent$$anonfun$extractUsersIDsVal$1 100% (1/ 1) 100% (1/ 1)
DataContent$$anonfun$extractUsersNameVal$1 0% (0/ 1) 0% (0/ 1)
total 89.5% (17/ 19) 91.9% (34/ 37)
Could anyone enlight me, please?

Related

redis consuming way more memory than keys occupy

Redis is taking way more space in memory than the keys itself:
$ top
> ... 74,2% memory (10gb) 2:17.61 redis-server
But the keys takes no more than 500MB total, I checked using "memory usage" on all keys and summed.
There is something I noticed while running "memory stats":
1) "peak.allocated"
2) (integer) 12556833800
3) "total.allocated"
4) (integer) 12141956128
5) "startup.allocated"
6) (integer) 803216
7) "replication.backlog"
8) (integer) 0
9) "clients.slaves"
10) (integer) 0
11) "clients.normal"
12) (integer) 11537845808
13) "aof.buffer"
14) (integer) 0
15) "lua.caches"
16) (integer) 180552
17) "db.0"
18) 1) "overhead.hashtable.main"
2) (integer) 474232
3) "overhead.hashtable.expires"
4) (integer) 115256
19) "overhead.total"
20) (integer) 11539419064
21) "keys.count"
22) (integer) 8579
23) "keys.bytes-per-key"
24) (integer) 1415217
25) "dataset.bytes"
26) (integer) 602537064
27) "dataset.percentage"
28) "4.9627666473388672"
29) "peak.percentage"
30) "96.695999145507812"
31) "allocator.allocated"
32) (integer) 12143577352
33) "allocator.active"
34) (integer) 12207005696
35) "allocator.resident"
36) (integer) 12250742784
37) "allocator-fragmentation.ratio"
38) "1.005223274230957"
39) "allocator-fragmentation.bytes"
40) (integer) 63428344
41) "allocator-rss.ratio"
42) "1.0035829544067383"
43) "allocator-rss.bytes"
44) (integer) 43737088
45) "rss-overhead.ratio"
46) "0.99665284156799316"
47) "rss-overhead.bytes"
48) (integer) -41005056
49) "fragmentation"
50) "1.0055875778198242"
51) "fragmentation.bytes"
52) (integer) 67843576
There is this clients.normal that is taking all that memory space. Any ideas on how to debug?
This keeps going until it crashes.
1) "peak.allocated"
2) (integer) 12556833800
Because the peak allocated memory is about 10GB. Although you removed many keys, the memory is not return to operation system. Check this for detail.
In order to decrease the memory consumption, you can restart Redis server.

How does this time complexity reduce?

Suppose I have two factors, N and M, and a constraint that M <= N, and I have an operation with O(log(N)) time complexity, that needs to be run M times, however, N reduces by 1 on each iteration, so it looks roughly like this:
O(log(N) + log(N - 1) + ... + log(N - (M - 2)) + log(N - (M - 1)))
How do I reduce this to a simple expression?
as a bonus, I kind of simplified things above, N doesn't definitely reduce by 1 on each iteration, this only occurs in the worst case (where M = N), it actually reduces by the result of the prior log(N) operation, which is some series of M numbers, lets call it series R, and series R sums to N, so it's really like:
O(log(N) + log(N - R(0)) + log(N - R(0) - R(1)) + ... + log(N - R(0) - R(1) - ... - R(M - 2)) + log(N - R(0) - R(1) - ... - R(M - 2) - R(M - 1)))
where it's a summation with sub summations... is this able to be simplified?
Since log(a) + log(b) = log(a*b) it follows that your equation equals:
O( log( N*(N-1)*(N-2)* ... * (N-(M-1)) * (N-M) ) )
So for the worst case scenario M=N-1 gives the upper bound O(log(N!))
In the general case the complexity is O(log(N!/(N-M)!)). Which increases with M as expected.

complexity of the sum of the squares of geometric progression

I have a question in my data structure course homework and I thought of 2 algorithms to solve this question, one of them is O(n^2) time and the other one is:
T(n) = 3 * n + 1*1 + 2*2 + 4*4 + 8*8 + 16*16 + ... + logn*logn
And I'm not sure which one is better.
I know that the sum of geometric progression from 1 to logn is O(logn) because I can use the geometric series formula for that. But here I have the squares of the geometric progression and I have no idea how to calculate this.
You can rewrite it as:
log n * log n + ((log n) / 2) * ((log n) / 2) + ((log n) / 4) * ((log n) / 4) ... + 1
if you substitute (for easier understanding) log^2 n with x, you get:
x + x/4 + x/16 + x/64 + ... + 1
You can use formula to sum the series, but if you dont have to be formal, then basic logic is enough. Just imagine you have 1/4 of pie and then add 1/16 pie and 1/64 etc., you can clearly see, it will never reach whole piece therefore:
x + x/4 + x/16 + x/64 + ... + 1 < 2x
Which means its O(x)
Changing back the x for log^2 n:
T(n) = O(3*n + log^2 n) = O(n)

Multi-Threading/Task making minimal difference, how to speed up process

I feel like I am doing something wrong here and not sure what, because I am not noticing a big difference with respect to multi-threading.
I have a 'Convert_Data' function that does a fair amount of processing of data. I tested it using 1 Task and saw that it was able to finish in 8 Seconds. When attempting to split the work into 4 task the overall reduction was just 2 seconds. I was expecting for it to atleast cut processing in half?
t1 = Task.Factory.StartNew(Sub() Convert_Data(Filter, 0, CInt(GridView1.RowCount / 4)))
t2 = Task.Factory.StartNew(Sub() Convert_Data(Filter, CInt(GridView1.RowCount / 4) + 1, CInt(GridView1.RowCount / 2)))
t3 = Task.Factory.StartNew(Sub() Convert_Data(Filter, CInt(GridView1.RowCount / 2) + 1, CInt(GridView1.RowCount / 3)))
t4 = Task.Factory.StartNew(Sub() Convert_Data(Filter, CInt(GridView1.RowCount / 3) + 1, GridView1.RowCount))
I break up the task based on the number of rows in my gridview. So each task gets a quarter of the files to process. I am very new to tasks and not sure if I am doing something wrong. Any comments/suggestions?
I noticed task 4 takes a fair amout longer to complete as opposed to the others.
The Conver_Data sub (Filter, StarRow, End Row)
So if there are 100 files;
Task 1 will go from 0 - 25
Task 2 will go from 26 - 50
Task 3 will go from 51 - 75 &
Task 4 will go from 76 - 100
Shouldn't the code read something like...
t1 = Task.Factory.StartNew(Sub() Convert_Data(Filter, 0, CInt (GridView1.RowCount / 4)))
t2 = Task.Factory.StartNew(Sub() Convert_Data(Filter, CInt(GridView1.RowCount / 4) + 1, CInt(GridView1.RowCount / 2)))
t3 = Task.Factory.StartNew(Sub() Convert_Data(Filter, CInt(GridView1.RowCount / 2) + 1, CInt(3 * GridView1.RowCount / 4)))
t4 = Task.Factory.StartNew(Sub() Convert_Data(Filter, CInt(3 * GridView1.RowCount / 4) + 1, GridView1.RowCount))
As things stand, your first task appears to do 1/4 of the work, the second another quarter, the third 1/6th of it, and the last 2/3rds of the job.

How to get value in percentage (%) or pixel (px) after doing some maths? | Lesscss

I've a little and simple question regarding Lesscss. How I can get calculated value in percentage or pixel in Lesscss. Like, I have this : ((1 / 1) * 1) = 1. I know the answer is 1, but I want this "1" to be in percentage or pixel like this: "1%" or "1px".
I just need to insert or put percentage (%) or pixel (px) sign in the calculated value.
I'd appreciate the help.
use:
unit(#yourvalue,px)
or
unit(#yourvalue,~"%")
read more here
Additional note:
by default the first occurring unit in the calculation will be assigned to the result. For example unit((1 / 2 * 3),px); and (1px / 2% * 3rem) will both return 1.5px.
I got the solution. What's required is to simply multiply (1%) or (1px) with the calculated value.
For Percentage: ((1 / 1) * 1) * 1% = 1%
For Pixel: ((1 / 1) * 1) * 1px = 1px
Good Luck! (Y).