performance – Generate a random number from a binomial distribution

In my Monte Carlo simulation application, the key is to generate a random number from a binomial distribution with the parameters n = size and p = 0.5. Here is my current implementation

#understand 
#understand 
#understand 

int64_t rbinom (size int64_t) {
if (! size) {
returns 0;
}

int64_t result = 0;
while (size> = 64) {
uint64_t random64;
while (! _rdrand64_step (& random64)) {
fprintf (stderr, "HW_RND_GEN not ready  n");
}
result + = _popcnt64 (random64);
size - = 64;
}

uint64_t random64;
while (! _rdrand64_step (& random64)) {
fprintf (stderr, "HW_RND_GEN not ready  n");
}
result + = _popcnt64 (random64 & ~ (UINT64_MAX << size));

return the result;
}

However, the result of the comparative analysis terrifies me:

enter the description of the image here

I spend 99.68% of the run time on this function! How can I optimize it?

The result does not need to be cryptographically secure, as long as it is sufficient for Monte Carlo simulations.

performance – Optimizing VBA code (loops)

I've added a timer to my code and the bottleneck occurs when I'm browsing 47 lines and I'm entering data from a dictionary that I've previously loaded with values .

As I use these files for many different things, I have configured public variables to avoid configuring them for each new code.

Timer statistics:

3.4453125 Open the customer database, determine the account on which we are
3.484375 Find the last 4 weeks and the range of commands
7.31640625 Adding columns and formatting
7.61328125 Looped over the last 4 weeks, add station clearance and result count data to the dictionary
7.6484375 Cumulative Value Range, Added Game and P & L for 2019
100.90234375 adding dictionary data to the command file

Whatever it is, below is the code …

Sub Orders_Historicals_autofilterdict ()

Dim start As Double
start = timer

& # 39; & # 39; ------------------------------------------
& # 39; & # 39; Static variables
& # 39; & # 39; ------------------------------------------
Call the defined variables

Dim orderFile As Variant
Dim orderStart As Long
Dim orderEnd As Long

Dim clientdataFile As Variant

Dim internalFile As Variant
Dim dateStart As Long
Dim stationStart As Long
Dim stationEnd As Long

Dim currentStation As String
Dim currentWeek As String

Dim dictData As New Scripting.Dictionary
Dim stationclearanceData As New Scripting.Dictionary
Dim stationplData As New Scripting.Dictionary

Dim key as variant

Dim fileOnly As String
Dim NetworkOnly As String

Dim i as long
Dim w as long
Dim t as long

Dim Plotale Long
Dim clearTotal As Long
Dim stationHash As String

& # 39; & # 39; ------------------------------------------
& # 39; & # 39; Dictionary of abbreviations of order
& # 39; & # 39; ------------------------------------------
Application.ScreenUpdating = False

Set orderFile = ActiveWorkbook.ActiveSheet

Workbooks.Open clientdataLocation

Set clientdataFile = ActiveWorkbook.Sheets (dan_location) Edit sheet when using on another computer

clientdataFile.Activate

For i = 1 To Cells (Rows.count, 1) .End (xlUp) .row
If dictData.Exists (Cells (i, clientOrder) .Value), then
Otherwise: dictData.Add Cells (i, clientOrder) .Value, i
End if
following

& # 39; & # 39; ------------------------------------------
& # 39; & # 39; Determine the account / network and open internal associated with the command
& # 39; & # 39; ------------------------------------------
orderFile.Activate

fileOnly = ActiveWorkbook.Name

fileOnly = Left (fileOnly, InStr (fileOnly, ".") - 1)

If InStr (fileOnly, 2)> 0 or InStr (fileOnly, 3)> 0 then
fileOnly = Left (fileOnly, Len (fileOnly) - 1)
End if

networkOnly = ActiveWorkbook.Name

networkOnly = Mid (networkOnly, InStr (networkOnly, "IO.") + 3)

networkOnly = Left (networkOnly, InStr (networkOnly, ".") - 1)

Workbooks.Open File name: = clientdataFile.Cells (dictData (fileOnly), clientInternal) .Value

Set internalFile = ActiveWorkbook

internalFile.Sheets (WT_newWeek) .Activate

Debug.Print Timer - start & "Open the client database, determine the account we are on"
& # 39; & # 39; ------------------------------------------
& # 39; & # 39; Find the last 4 dates and column header for orders
& # 39; & # 39; ------------------------------------------
For i = 1 to 700
If the cells (i, 1) = WT_newWeek Then
dateStart = i
ElseIf Cells (i, 1) = "Station" Then
stationStart = i + 1
Output for
End if
following

For i = stationStart To 700
If Cells (i, 1) .Value = Cells (stationStart - 2, 1) .Value & "Total" Then
stationEnd = i - 1
Output for
End if
following

orderFile.Activate

For i = 1 to 700
If Cells (i, 1) = "Station", then
orderStart = i + 1
Output for
End if
following

For i = orderStart To 700
If Len (Cells (i, 1)) = 0 And Len (Cells (i - 1, 1)) = 0 And Len (Cells (i - 2, 1)) = 0 Then
orderEnd = i - 3
Output for
End if
following


Debug.Print Timer - start & "Find the last 4 weeks and the range of commands"

& # 39; & # 39; ------------------------------------------
& # 39; & # 39; Add dates to the header and formatting of the command
& # 39; & # 39; ------------------------------------------

Cells (orderStart - 1, OF_buyAlgoColumn) = "Algorithm Recommendation"
Cells (orderStart - 1, OF_totalplColumn) = "Total P & L"
Cells (orderStart - 1, OF_totalclearanceColumn) = "% of total clearance"

Cells (orderStart - 1, OF_clearanceColumn1) = internalFile.Sheets (WT_newWeek) .Cells (dateStart, 1)
Cells (orderStart - 1, OF_clearanceColumn2) = internalFile.Sheets (WT_newWeek) .Cells (dateStart - 1, 1)
Cells (orderStart - 1, OF_clearanceColumn3) = internalFile.Sheets (WT_newWeek) .Cells (dateStart - 2, 1)
Cells (orderStart - 1, OF_clearanceColumn4) = internalFile.Sheets (WT_newWeek) .Cells (dateStart - 3, 1)

Cells (orderStart - 1, OF_plColumn1) = internalFile.Sheets (WT_newWeek) .Cells (dateStart, 1)
Cells (orderStart - 1, OF_plColumn2) = internalFile.Sheets (WT_newWeek) .Cells (dateStart - 1, 1)
Cells (orderStart - 1, OF_plColumn3) = internalFile.Sheets (WT_newWeek) .Cells (dateStart - 2, 1)
Cells (orderStart - 1, OF_plColumn4) = internalFile.Sheets (WT_newWeek) .Cells (dateStart - 3, 1)

Range (Cells (orderStart - 2, OF_clearanceColumn1), Cells (orderStart - 2, OF_clearanceColumn4)) = "Clearance"
Range (cells (orderStart - 2, OF_plColumn1), cells (orderStart - 2, OF_plColumn4)) = "P & L"

Cells (orderStart - 1, OF_stationColumn) .Copy
Range (cells (orderStart - 1, OF_buyAlgoColumn), cells (orderStart - 1, OF_plColumn4)). PasteSpecial xlPasteFormats

Cells (orderStart, OF_stationColumn) .Copy
Range (cells (orderStart - 2, OF_clearanceColumn1), cells (orderStart - 2, OF_plColumn4)). PasteSpecial xlPasteFormats

Range (cells (orderStart - 2, OF_buyAlgoColumn), cells (orderEnd, OF_plColumn4)). HorizontalAlignment = xlCenter

Cells (orderStart, OF_stationColumn) .Copy
Range (Cells (orderStart, OF_buyAlgoColumn), Cells (orderEnd, OF_plColumn4)). PasteSpecial xlPasteFormats

Cells (orderStart, OF_totalColumn) .Copy
Range (cells (orderStart, OF_plColumn1), cells (orderEnd, OF_plColumn4)). PasteSpecial xlPasteFormats
Range (cells (orderStart, OF_totalplColumn), cells (orderEnd, OF_totalplColumn)). PasteSpecial xlPasteFormats

Range (Cells (orderStart, OF_totalclearanceColumn), Cells (orderEnd, OF_clearanceColumn4)). NumberFormat = "0%"

Range (Cells (orderStart - 2, OF_buyAlgoColumn), Cells (orderEnd, OF_plColumn4)). FormatConditions.Delete

Range (Columns (OF_buyAlgoColumn), Columns (OF_plColumn4)). AutoFit

Debug.Print Timer - start & "Adding columns and formatting"

& # 39; & # 39; ------------------------------------------
& # 39; & # 39; Add clearance and income statement by date to dictionary
& # 39; & # 39; ------------------------------------------

For i = OF_clearanceColumn1 to OF_clearanceColumn4

currentWeek = Cells (orderStart - 1, i) .Value

internalFile.Sheets (currentWeek) .Activate

For t = 1 to 700

If Cells (t, 1) = "Station", then
stationStart = t + 1
Output for
End if
following

For t = stationStart To 700

If Cells (t, 1) .Value = Cells (stationStart - 2, 1) .Value & "Total" Then
stationEnd = i - 1
Output for
End if

If stationclearanceData.Exists (Cells (t, WT_stationColumn) .Value & currentWeek) Then
Other:
In case of error, next recovery
stationclearanceData.Add Cells (t, WT_stationColumn) .Value & currentWeek, Cells (t, WT_mediaactColumn) .Value / Cells (t, WT_mediaestColumn) .Value
stationplData.Add Cells (t, WT_stationColumn) .Value & currentWeek, Cells (t, WT_profitColumn) .Value
End if

following

orderFile.Activate

following

Debug.Print Timer - begins and "loops the last 4 weeks, adds station clearance and P & L data to dictionary"

& # 39; & # 39; ------------------------------------------
& # 39; & # 39; Add the cumulative balance and income statement to the dictionary
& # 39; & # 39; ------------------------------------------

internalFile.Sheets ("Cumulative"). Activate

For t = 5 to 70,000

If the cells (t, 1) = "" and the cells (t + 1, 1) = "" and the cells (t + 2, 1) = ""
stationEnd = t + 1
Output for
End if
following

For t = 5TB stationEnd

If cells (t, CT_yearColumn) = 2019 then

If stationclearanceData.Exists (Cells (t, CT_hashColumn) .Value) Then
Other:
In case of error, next recovery
stationclearanceData.Add Cells (t, CT_hashColumn) .Value, Cells (t, CT_clearanceColumn) .Value
stationplData.Add Cells (t, CT_hashColumn) .Value, Cells (t, CT_invoiceColumn) .Value - Cells (t, CT_actcostColumn) .Value
End if
End if
following

Debug.Print Timer - start & "search for a range of cumulative values, addition of clearance and income statement for 2019"


orderFile.Activate

& # 39; & # 39; ------------------------------------------
& # 39; & # 39; Stations looped on command file and updated according to dictionary values
& # 39; & # 39; ------------------------------------------

For w = orderStart To orderEnd

If the cells (w, OF_stationColumn) <> "" then

If cells (w, OF_stationColumn) <> cells (w - 1, OF_stationColumn), then

stationHash = Cells (w, OF_stationColumn) .Value & "" & Cells (w, OF_trafficColumn) .Value & "Total"

In case of error, next recovery
Cells (w, OF_clearanceColumn1) = stationclearanceData (Cells (w, OF_stationColumn) .Value & Cells (orderStart - 1, OF_clearanceColumn1) .Value)
Cells (w, OF_clearanceColumn2) = stationclearanceData (Cells (w, OF_stationColumn) .Value & Cells (orderStart - 1, OF_clearanceColumn2) .Value)
Cells (w, OF_clearanceColumn3) = stationclearanceData (Cells (w, OF_stationColumn) .Value & Cells (orderStart - 1, OF_clearanceColumn3) .Value)
Cells (w, OF_clearanceColumn4) = stationclearanceData (Cells (w, OF_stationColumn) .Value & Cells (orderStart - 1, OF_clearanceColumn4) .Value)

Cells (w, OF_plColumn1) = stationplData (Cells (w, OF_stationColumn) .Value & Cells (orderStart - 1, OF_plColumn1) .Value)
Cells (w, OF_plColumn2) = stationplData (Cells (w, OF_stationColumn) .Value & Cells (orderStart - 1, OF_plColumn2) .Value)
Cells (w, OF_plColumn3) = stationplData (Cells (w, OF_stationColumn) .Value & Cells (orderStart - 1, OF_plColumn3) .Value)
Cells (w, OF_plColumn4) = stationplData (Cells (w, OF_stationColumn) .Value & Cells (orderStart - 1, OF_plColumn4) .Value)

Cells (w, OF_totalplColumn) = stationplData (stationHash)
Cells (w, OF_totalclearanceColumn) = stationclearanceData (stationHash)

End if

End if

following

Debug.Print Timer - starts and "adds dictionary data to the command file"

clientdataFile.Activate

ActiveWorkbook.Close saveChanges: = False

Application.ScreenUpdating = True

Range (cells (orderStart - 2, OF_buyAlgoColumn), cells (orderEnd, OF_plColumn4)). HorizontalAlignment = xlCenter

MsgBox ("Buy the complete algorithm")


End Sub

performance – Barycentric rendering of the processor in JavaFX / Kotlin

I'm writing a rendering engine for Dear ImGui port Kotlin. In order to be complete, I needed to add a barycentric color to some triangles for items such as color pickers. I've implemented the barycentric erndering below, but it takes between 75 and 95% of the time spent on the processor to calculate it. Are there better methods that I could use?

Some performance information (in ns):

Start 12 barycentric triangles: 40% of the time. This seems to be due to the fact that the rest of the pipeline is heating up.
total time 2673419, bary time 1204929, or 45.07071% bary time. Bary draws 12 Tex Draws 311 Times Normal 443 Draws Normal 365

Long stroke 12 barycentric triangles: 75% of the time
total time 1384237, bary time 1034258 is 74.71683% bary time. Bary draws 12 Tex Draws 311 Times Normal 443 Draws Normal 365

Long duration of 28 barycentric triangles: 95% of the time
total time 18795482, bary time 17941069 is 95.45416% bary time. Bary draws 28 Tex draws 351 Normal time 673 Normal draws 575

gc is a GraphicsContext.

vtx1, vtx, vtx3 are the vertices of this triangle.

vt1, vt2, vt3 are the ordered vertices such as vt1.y> = vt2.y> = vt3.y

// set up so that vt1.y> = vt2.y> = vt3.y
val vt3 = if (vtx1.pos.y> vtx2.pos.y) if (vtx1.pos.y> vtx3.pos.y) vtx1 else vtx3 else if (vtx2.pos.y> vtx3.pos.y) vtx2 otherwise vtx3
val vt1 = if (vtx1.pos.y <vtx2.pos.y) if (vtx1.pos.y <vtx3.pos.y) vtx1 else vtx3 else if (vtx2.pos.y <vtx3.pos.y) vtx2 otherwise vtx3

// process of elimination
val vt2 = if (vt1 == vtx1)
if (vt3 == vtx2)
vtx3
other
vtx2
other
if (vt1 == vtx2)
if (vt3 == vtx3)
vtx1
other
vtx3
other
if (vt3 == vtx2)
vtx1
other
vtx2

// set up all the constant barycentric links for this triangle
val v0 = vt2.pos - vt1.pos
val v1 = vt3.pos - vt1.pos

val d00 = dotProd (v0, v0)
val d01 = dotProd (v0, v1)
val d11 = dotProd (v1, v1)

denomination = d00 * d11 - d01 * d01
// end of the configuration

/ **
* Draw the color in focus [p] based on the currently configured barycentric triangle
* /
fun baryColor (p: Vec2) {
// get the rest of the barycentric information
val v2 = p - vt1.pos
val d20 = dotProd (v2, v0)
val d21 = dotProd (v2, v1)
val v = (d11 * d20 - d01 * d21) / denomination
val w = (d00 * d21 - d01 * d20) / denomination
val u = 1.0 - v - w
// turn colors into usable colors
val c1 = vt1.col.toJFXColor ()
val c2 = vt2.col.toJFXColor ()
val c3 = vt3.col.toJFXColor ()
// mix colors according to their implication, and fix [0.0,1.0]
    // u, v, w can be negative
gc.fill = JFXColor (
((c1.red * u) + (c2.red * v) + (c3.red * w)). coerceIn (0.0, 1.0),
((c1.green * u) + (c2.green * v) + (c3.green * w)). coerceIn (0.0, 1.0),
((c1.blue * u) + (c2.blue * v) + (c3.blue * w)). coerceIn (0.0, 1.0),
((c1.opacity * u) + (c2.opacity * v) + (c3.opacity * w)). coerceIn (0.0, 1.0)
)
// draw a rectangle 1x1 in `p`
gc.fillRect (p.x.d, p.y.d, 1.0, 1.0)
}

/ **
* Draw a flat triangle at the bottom with a barycentric color mix
* /
fun fillingBottomFlatTriangle (vs1: Vec2, vs2: Vec2, vs3: Vec2) {
// get the reverse slopes of the lines because we are going to multiply by y and need x offset
val invslope1p = (vs2.x - vs1.x) / (vs2.y - vs1.y)
val invslope2p = (vs3.x - vs1.x) / (vs3.y - vs1.y)

// order them correctly so that invslope1 < invslope2
    val (invslope1, invslope2) = if (invslope1p > invslope2p) Even (invslope2p, invslope1p) else Even (invslope1p, invslope2p)

// on the first line starts at a point
var curx1 = vs1.x
var curx2 = vs1.x

// get the min and max values
val minY = vs1.y
val maxY = vs3.y

// we ordered them by y but nothing by x, so we get the max and min x by comparing all the values
minX vs = vs3.x min vs2.x min vs1.x
maxX max = vs3.x max vs2.x max vs1.y

// it's a line, must be specially drawn so that only 1 pixel is not drawn
if (maxY - minY> 1.0f) {
// for each value y in the triangle
for (scanlineY in Math.round (minY) .i..Math.round (maxY) .i) {
// for each x value on the line
for (x in Math.round (curx1) .i..Math.round (curx2) .i) {
// draw the color at the given point
baryColor (Vec2 (x, scanlineY))
}
curx1 + = invslope1
curx2 + = invslope2
curx1 = curx1.coerceAtLeast (minX) // if the difference between y is less than 1, it will correctly block the x
curx2 = curx2.coerceAtMost (maxX) // if the difference between y is less than 1, it will correctly block the x
}
} other {
// average where the line goes
val scanY = (maxY + minY) / 2.0f
for (x in Math.round (minX) .i..Math.round (maxX) .i) {
// draw the color at each point of the line
baryColor (Vec2 (x, scanlineY))
}
}
}

/ **
* Draw a flat triangle with a barycentric color mix
*
* For more information on the steps, similar to fillBottomFlatTriangle
* /
fun fillTopFlatTriangle (vs1: Vec2, vs2: Vec2, vs3: Vec2) {
val invslope1p = (vs3.x - vs1.x) / (vs3.y - vs1.y)
val invslope2p = (vs3.x - vs2.x) / (vs3.y - vs2.y)

val (invslope1, invslope2) = if (invslope1p> invslope2p) pair (invslope1p, invslope2p) else pair (invslope2p, invslope1p)

var curx1 = vs3.x
var curx2 = vs3.x

val maxY = vs3.y
val minY = vs1.y

minX vs = vs3.x min vs2.x min vs1.x
maxX max = vs3.x max vs2.x max vs1.y

if (maxY - minY> 1.0f) {
for (scanlineY in Math.round (maxY) .i downTo Math.round (minY) .i) {
for (x in Math.round (curx1) .i..Math.round (curx2) .i) {
baryColor (Vec2 (x, scanlineY))
}
curx1 - = invslope1
curx2 - = invslope2
curx1 = curx1.coerceAtLeast (minX)
curx2 = curx2.coerceAtMost (maxX)
}
} other {
val scanY = (maxY + minY) / 2.0f
for (x in Math.round (minX) .i..Math.round (maxX) .i) {
baryColor (Vec2 (x, scanlineY))
}
}
}

// check whether it is an upper, lower, or general triangle
when {
vt2.pos.y == vt3.pos.y -> {
fillBottomFlatTriangle (vt1.pos, vt2.pos, vt3.pos)
}
vt1.pos.y == vt2.pos.y -> {
fillTopFlatTriangle (vt1.pos, vt2.pos, vt3.pos)
}
otherwise -> {
/ * general case - divides the triangle into a flat / lower triangle * /
v4 = Vec2 ((vt1.pos.x + (vt2.pos.y - vt1.pos.y) / / vt3.pos.y - vt1.pos.y) * (vt3.pos.x - vt1.pos .x)), vt2.pos.y)
fillBottomFlatTriangle (vt1.pos, vt2.pos, v4)
fillTopFlatTriangle (vt2.pos, v4, vt3.pos)
}
}

In addition, removing general case reports does not have a significant impact on performance.

If you could benefit from any other information, please comment and I will add it for you. Thanks in advance!

Amazon Web Services – PHP-FPM – Optimizing Performance and Using the CPU

I have a Web application written in Laravel / PHP which is in its infancy and usually serves 500 – 600 requests / min. We use Maria DB and Redis for caching and everything is on AWS.

For the events we want to promote on our platform, we send a push notification (mobile platform) to all users, which generates a traffic burst of about 2 min that leads us to 3.5k reqs / min

At the scale of our current server, this completely slows down the application server processor, which typically runs around 10% of CPU. Redis databases and clusters seem to work well during this burst.

Looking at the logs, it appears that all processes in the PHP-FPM work pool are busy and are starting to queue Nginx requests upstream.

We currently have:

  • Three m4.large servers (2 cores, 8 GB RAM each)

  • dynamic management of PHP-FPM processes, with a maximum of 120 child process (servers) on each box

My questions:

1) Should we increase the FPM pool? It seems that in terms of memory, we are probably approaching our limit

2) should we decrease the FPM pool? It seems possible that we are accumulating so many processes that the processor is bogged down and fails to finish one of them.

3) Should we simply use larger boxes with more RAM and CPU, which will allow us to add more FPM workers?

4) Is there a FPM performance tuning that we should consider? However, we use Opcache. Should we move to static process management for FPM to reduce indirect costs associated with rotating processes?

posts – Removing unwanted style sheets and scripts with the help of a plug-in to improvze page performance

I have already installed the resource cleanup plug-in for deleting CSS files and unwanted scripts. The plug-in does not contain the option of bulk unloading without certain pages and types of specific publications.

Ex:
I am discharge the particular css file on all over The css file is unloaded on all pages, but I want the css file on the entire documentation pages. I have a lot of child pages of documentation. My problem is that I'm added on load this page only – option on each documentation page.

1. It takes too much time. Because I have a lot of children's pages.

2 Any better plugin is there with the option mentioned above.

3 Does this type of option already exist in the Asset Cleanup plugin?

android – Pixels in excess of multiple polygons, which affects performance the most?

I know that it is not recommended to have pixels superimposed and to have a lot of polygons because they can reduce the performances.
Often, when modeling, I have the possibility to reduce the number of polygons by letting go of disconnected polygons. For example, considering this:texture
Imagine that there are more turns that are not visible in this image.
I can reduce the number of polygons by having a path as a single disconnected face:
enter the description of the image here
As a result, I would have fewer polycompts, but the lower geometry would be overused in many areas.

Or I can model it as one continuous mesh. As a result, I would have more poly-accounts, but no surplus:
enter the description of the image here
I have very often similar situations and I wonder which of these would be the most efficient in terms of performance and would result in decreased performance on mobile devices?

performance tuning – imaginary part of the expression too difficult to calculate

I'm trying to calculate the imaginary part of a long phrase. This is a pretty long phrase that Mathematica "hangs" when you run:

imFUN2 = ComplexExpand[Im[expression]];

Can I do something that can help speed things up?

Here is my complete code:

expression = - ((I [CapitalOmega]c (4 [Gamma]a ^ 4 +
16 [CapitalDelta]d4 -
48 [CapitalDelta]d ^ 3 [CapitalDelta]p +
48 [CapitalDelta]d ^ 2 [CapitalDelta]p ^ 2 -
16 [CapitalDelta]re[CapitalDelta]p ^ 3 +
4 I[Gamma]a ^ 3 (3 [CapitalDelta]c + 6 [CapitalDelta]re -
4 [CapitalDelta]p - [CapitalDelta]s) -
16 [CapitalDelta]d ^ 3 [CapitalDelta]s +
32 [CapitalDelta]d ^ 2 [CapitalDelta]p[CapitalDelta]s -
16 [CapitalDelta]re[CapitalDelta]p ^ 2 [CapitalDelta]s -
4 [CapitalDelta]d ^ 2 [CapitalOmega]c ^ 2 +
4 [CapitalDelta]re[CapitalDelta]p[CapitalOmega]c ^ 2 +
4 [CapitalDelta]re[CapitalDelta]s [CapitalOmega]c ^ 2 -
4 I'm degrading [CapitalDelta]re[CapitalOmega]d ^ 2 +
12 [CapitalDelta]d ^ 2 [CapitalOmega]d ^ 2 +
4 I'm degrading [CapitalDelta]p[CapitalOmega]d ^ 2 -
24 [CapitalDelta]re[CapitalDelta]p[CapitalOmega]d ^ 2 +
12 [CapitalDelta]p ^ 2 [CapitalOmega]d ^ 2 -
8 [CapitalDelta]re[CapitalDelta]s [CapitalOmega]d ^ 2 +

8 [CapitalDelta]p[CapitalDelta]s [CapitalOmega]d ^ 2 - 
[CapitalOmega]c ^ 2 [CapitalOmega]d ^ 2 + [CapitalOmega]d4 +
4 [CapitalDelta]c ^ 2 (4 [CapitalDelta]d ^ 2 -
4 [CapitalDelta]re[CapitalDelta]p + 
[CapitalOmega]d ^ 2) -
2 [Gamma]a ^ 2 (4 [CapitalDelta]c ^ 2 +
26 [CapitalDelta]d ^ 2 + 10 [CapitalDelta]p ^ 2 +
2 [CapitalDelta]c (13 [CapitalDelta]re -
7 [CapitalDelta]p - 2 [CapitalDelta]s) +
6 [CapitalDelta]p[CapitalDelta]s -
2 [CapitalDelta]d (18 [CapitalDelta]p +
5 [CapitalDelta]s) - [CapitalOmega]c ^ 2 +
4 [CapitalOmega]d ^ 2) +
4 [CapitalDelta]c (8 [CapitalDelta]d ^ 3 -
4 [CapitalDelta]d ^ 2 (4 [CapitalDelta]p + 
[CapitalDelta]s) - (4 [CapitalDelta]p + [CapitalDelta]s)
[CapitalOmega]d ^ 2 + [CapitalDelta]d (8 [CapitalDelta]p ^ 2 +
4 [CapitalDelta]p[CapitalDelta]s - 
[CapitalOmega]c ^ 2 + 4 [CapitalOmega]d ^ 2)) -
2 I [Gamma]one (24 [CapitalDelta]d ^ 3 +
4 [CapitalDelta]c ^ 2 (3 [CapitalDelta]re -
[CapitalDelta]p) - 4 [CapitalDelta]p ^ 3 -
4 [CapitalDelta]p ^ 2 [CapitalDelta]s -
4 [CapitalDelta]d ^ 2 (13 [CapitalDelta]p +
4 [CapitalDelta]s) + [CapitalDelta]p
[CapitalOmega]c ^ 2 + [CapitalDelta]s [CapitalOmega]c ^ 2 -
2 I'm degrading [CapitalOmega]d ^ 2 -
ten[CapitalDelta]p[CapitalOmega]d ^ 2 -
3 [CapitalDelta]s [CapitalOmega]d ^ 2 + [CapitalDelta]c
(36)[CapitalDelta]d ^ 2 + 8 [CapitalDelta]p ^ 2 +
4 [CapitalDelta]p[CapitalDelta]s -
4 [CapitalDelta]d (11 [CapitalDelta]p +
3 [CapitalDelta]s) - [CapitalOmega]c ^ 2 +
7 [CapitalOmega]d ^ 2) + [CapitalDelta]d (32 
[CapitalDelta]p ^ 2 + 20 [CapitalDelta]p[CapitalDelta]s -
3 [CapitalOmega]c ^ 2 +
ten[CapitalOmega]d ^ 2)))) / (([Gamma]a +
2 I [CapitalDelta]d) (2 [Gamma]a ^ 2 -
4 [CapitalDelta]c ^ 2 +
4 [CapitalDelta]re[CapitalDelta]p -
4 [CapitalDelta]p ^ 2 +
4 [CapitalDelta]re[CapitalDelta]s -
8 [CapitalDelta]p[CapitalDelta]s -
4 [CapitalDelta]s ^ 2 +

2 I [Gamma]one (3 [CapitalDelta]c + [CapitalDelta]re -
3 ([CapitalDelta]p + [CapitalDelta]s)) + 
[CapitalDelta]c (-4)[CapitalDelta]d +
8 ([CapitalDelta]p + [CapitalDelta]s)) + 
[CapitalOmega]d ^ 2) (4 I [Gamma]a ^ 3 ([CapitalDelta]c - 
[CapitalDelta]p) -
16 [CapitalDelta]c ^ 2 [CapitalDelta]re[CapitalDelta]p -
16 [CapitalDelta]c[CapitalDelta]d ^ 2 [CapitalDelta]p +
16 [CapitalDelta]c ^ 2 [CapitalDelta]p ^ 2 +
48 [CapitalDelta]c[CapitalDelta]re[CapitalDelta]p ^ 2 +
16 [CapitalDelta]d ^ 2 [CapitalDelta]p ^ 2 -
32 [CapitalDelta]c[CapitalDelta]p ^ 3 -
32 [CapitalDelta]re[CapitalDelta]p ^ 3 +
16 [CapitalDelta]p ^ 4 -
4 [CapitalDelta]c[CapitalDelta]re[CapitalOmega]c ^ 2 -
4 [CapitalDelta]d ^ 2 [CapitalOmega]c ^ 2 +
8 [CapitalDelta]c[CapitalDelta]p[CapitalOmega]c ^ 2 +
8 [CapitalDelta]re[CapitalDelta]p[CapitalOmega]c ^ 2 -
8 [CapitalDelta]p ^ 2 [CapitalOmega]c ^ 2 + 
[CapitalOmega]c ^ 4 - 4 [CapitalDelta]c ^ 2 [CapitalOmega]d ^ 2 -
4 [CapitalDelta]c[CapitalDelta]re[CapitalOmega]d ^ 2 +
8 [CapitalDelta]c[CapitalDelta]p[CapitalOmega]d ^ 2 +
8 [CapitalDelta]re[CapitalDelta]p[CapitalOmega]d ^ 2 -
8 [CapitalDelta]p ^ 2 [CapitalOmega]d ^ 2 -
2 [CapitalOmega]c ^ 2 [CapitalOmega]d ^ 2 + 
[CapitalOmega]d4 +
2 [Gamma]a ^ 2 (-4 [CapitalDelta]c ^ 2 -
6 [CapitalDelta]c[CapitalDelta]d +
14 [CapitalDelta]c[CapitalDelta]p +
6 [CapitalDelta]re[CapitalDelta]p -
ten[CapitalDelta]p ^ 2 + [CapitalOmega]c ^ 2 + 
[CapitalOmega]d ^ 2) -
2 I [Gamma]one (4 [CapitalDelta]c ^ 2 ([CapitalDelta]re -
3 [CapitalDelta]p) -
4 [CapitalDelta]d ^ 2 [CapitalDelta]p + [CapitalDelta]re
(20 [CapitalDelta]p ^ 2 -
3 [CapitalOmega]c ^ 2 - [CapitalOmega]d ^ 2) + 
[CapitalDelta]c (4 [CapitalDelta]d ^ 2 -
24 [CapitalDelta]re[CapitalDelta]p +
28 [CapitalDelta]p ^ 2 -
3 [CapitalOmega]c ^ 2 - [CapitalOmega]d ^ 2) +
4 [CapitalDelta]p (-4)[CapitalDelta]p ^ 2 + 
[CapitalOmega]c ^ 2 + [CapitalOmega]d ^ 2)) +
2 out of phase (2 [Gamma]a ^ 3 +
2 I [Gamma]a ^ 2 (2 [CapitalDelta]c +
3 [CapitalDelta]re -
5 [CapitalDelta]p) + [Gamma]one (-4 
[CapitalDelta]d ^ 2 -
4 [CapitalDelta]c ([CapitalDelta]re -
3 [CapitalDelta]p) +
20 [CapitalDelta]re[CapitalDelta]p -
16 [CapitalDelta]p ^ 2 + [CapitalOmega]c ^ 2 + 
[CapitalOmega]d ^ 2) +
2 I (4 [CapitalDelta]d ^ 2 [CapitalDelta]p -
8 [CapitalDelta]re[CapitalDelta]p ^ 2 +
4 [CapitalDelta]p ^ 3 - [CapitalDelta]p
[CapitalOmega]c ^ 2 + [CapitalDelta]re[CapitalOmega]d ^ 2 - 
[CapitalDelta]p[CapitalOmega]d ^ 2 + [CapitalDelta]c (4 
[CapitalDelta]re[CapitalDelta]p -
4 [CapitalDelta]p ^ 2 + [CapitalOmega]d ^ 2)))))) /. 
{[Gamma]a -> 1, out of phase -> 10 ^ -4};
imFUN2 = ComplexExpand[Im[expression]];

tuning performance – Motion animation of waves in the water

Following this question that I found on MSE, I tried to reproduce

enter the description of the image here

d & # 39; here

it's all I've had:

fun[a_, b_, c_, x_, y_] : =
Point[{#[[1]]+ x, #[[2]]+ y} &[
    Part[CirclePoints[360] c
Yes[a + b == 360, 360, Mod[a + b, 360]]]]];
tab = with[{a = #}, 
     Flatten[Table[
       Table[fun[a, 90 + 15 n, 1 - .15 m, -1 + .5 n, -.35 m], {m, 0,
ten}], {n, 0, 24}], 1]]& /@ Interval[1, 360, 15];

Module[{t, x, y, fun, xf, yf, a}, x = -5; y = 1;
fun[a_, b_, c_, x_, y_] : =
Point[{#[[1]]+ x, #[[2]]+ y} &[
    Part[CirclePoints[360] c
Yes[a + b == 360, 360, Mod[a + b, 360]]]]];
xf[t_, a_, b_] : = a t - b Sin
animate[
  Show[
   Graphics[
    {PointSize[.01], tab[[a]]}
PlotRange -> {{-1 - x, 10 + x}, {-1 - y, 1}}
],
ParametricPlot[
    {(Pi/2) xf[t + 2 Pi a/24, 1.25, .6] - 4 Pi a / 24 - Pi ^ 2 + 0.05,
2.05 - 1.65 strong[t + 2 Pi a/24, 1.25, .6]}
{t, -4 Pi, 4 Pi}, Axes -> False
]],
{a, 1, 24, 1}, ControlPlacement -> Top, AnimationRate -> 5,
AnimationDirection -> Back
]]

which is not very effective (I'm sure Part more efficient), and despite various interventions, I could not get the cycloid to match the points.

What is the best way to approach this?

performance – How to customize HTML rendering by Auto_placeholder

Is there a way that allows me to change the HTML that makes by #lazy_builder
By default, the bigpipe module has been activated, reminders #lazy_builder and #create_placeholder have been added.
How can I use

instead of

Any help would be appreciated

performance – PHP: faster method to write an HTML string of about 100 KB on an MD file (iteration count ~ 10 KB)

That's what I meant in the comments

You could do substr ($ hey, 0.2) once, then check the first two letters instead of several strpos. Maybe, but I have no idea what $ hey looks like πŸ™‚ – but that you could switch on that and get rid of multiple function calls. I do not think it will be much faster, but with enough iterations, who knows, and it may sound a little cleaner.

        switch (substr ($ hay, 0,2)) {
case na na nasdaq
$ mk = & # 39; nasdaq-us & # 39 ;;
$ nasdaq ++
Pause;
case 'ny': // nyse
case #: // new york
$ mk = nyse-us & # 39 ;;
$ nyse ++;
Pause;
case & # 39; cb ;: // cboe
$ mk = & # 39; cboe-us & # 39 ;;
$ cboe ++;
Pause;
default:
$ mk = & # 39; market-us & # 39 ;;
$ other ++;
Pause;
}

In this way, you make 1 function call instead of 4.

It looks like your call strtolower more than 3 times on $ cn

        $ cn = strtolower (UpdateStocks :: slugCompany ($ s["quote"]["companyName"])); // s
// ...
$ p2 = sprintf (% s% s% s% s), self :: SLASH, strtolower ($ cn), - & # 39; - & # 39;
// ...
if (strtolower ($ symb) === strtolower ($ cn)) {
// ------------------
$ p1 = sprintf (% s% s% s% s), self :: SLASH, strtolower ($ symb), - & # 39; - & # 39;

if (strtolower ($ symb) === strtolower ($ cn)) {

And so on.

There may be other duplicate calls like this one.

Your sprintf seems less point.

    // symbol in the URL
$ p1 = sprintf (% s% s% s% s), self :: SLASH, strtolower ($ symb), - & # 39; - & # 39;
// company in url
$ p2 = sprintf (% s% s% s% s), self :: SLASH, strtolower ($ cn), - & # 39; - & # 39;

// you can just do this for example
$ p1 = self :: SLASH. $ symb - & # 39 ;;

All this piece is suspicious:

    // symbol in the URL
$ p1 = sprintf (% s% s% s% s), self :: SLASH, strtolower ($ symb), - & # 39; - & # 39;
// company in url
$ p2 = sprintf (% s% s% s% s), self :: SLASH, strtolower ($ cn), - & # 39; - & # 39;

// risk of duplication
if (strtolower ($ symb) === strtolower ($ cn)) {
// duplicate name of a symbol
$ previousNames = array_reverse (UpdateStocks :: searchFilenames (glob ($ dir. "/ *"), $ p2));
$ lurl = $ cn. & # 39; - & # 39; $ sc. & # 39; - & # 39; $ mk. & # 39; - & # 39; $ enc;
}other{
// duplicate name of a symbol
$ previousNames = array_reverse (UpdateStocks :: searchFilenames (glob ($ dir. "/ *"), $ p1));
$ lurl = strtolower ($ symb). & # 39; - & # 39; $ cn. & # 39; - & # 39; $ sc. & # 39; - & # 39; $ mk. & # 39; - & # 39; $ enc;
}

For example, the only difference is:

$ previousNames = array_reverse (UpdateStocks :: searchFilenames (glob ($ dir. "/ *"), $ p2));
$ previousNames = array_reverse (UpdateStocks :: searchFilenames (glob ($ dir. "/ *"), $ p1));
//and
$ lurl = $ cn. & # 39; - & # 39; $ sc. & # 39; - & # 39; $ mk. & # 39; - & # 39; $ enc;
$ lurl = $ symb. & # 39; - & # 39; $ cn. & # 39; - & # 39; $ sc. & # 39; - & # 39; $ mk. & # 39; - & # 39; $ enc; 

So, if you could change the last argument and add $ symbyou may be able to eliminate this condition. I have to think a little … lol. But you see what I mean, it could be drier (do not repeat yourself). I do not know enough about the data to really say about this one. I thought of something like this:

        if ($ symb! = $ cn) {
$ p = self :: SLASH. $ symb - & # 39 ;;
$ lurl = & # 39;
}other{
$ p = self :: SLASH. $ cn. - & # 39 ;;
$ lurl = $ symb;
}

$ previousNames = array_reverse (UpdateStocks :: searchFilenames (glob ($ dir. "/ *"), $ p));
$ lurl. = "$ cn- $ sc- $ mk- $ enc";

But I'm not sure if I've detained everything, lol. So be sure to test it. It's a little hard to work in my head. You still need a condition, but it is much shorter and easier to read.

For this one:

searchFilenames

/ **
*
* @return an array with the path values ​​of all md files before being stored
* /
public static function searchFilenames ($ array, $ re) {
$ arr = array ();
foreach ($ array like $ k => $ str) {
$ pos = strpos ($ str, $ re);
if ($ pos! == false) {
array_push ($ arr, $ str);
}
}
return $ arr;
}

You can use preg_grep. For example:

            public static function searchFilenames ($ array, $ re) {
return preg_grep (& # 39; / # 39;) preg_quote ($ re, & # 39;); & # 39; / i, # $ array);
}

your just find if $ re is contained in each element of $ table. preg_grep – Returns the table entries that match the template. This is also insensitive to the case with the I flag.

One thing I find useful is to take and add some examples of data values ​​to the code in the comments. Then you can visualize what is happening and if you repeat yourself.