How to visualize NodeJS .cpuprofile - node.js

I use v8-profiler to profile my NodeJS app. It generates a .cpuprofile file.
I used to be able to visualize the content of the file with Google Chrome built-in DevTools. However, Chrome recently changed the file format for profiling results and Chrome is no longer able to read .cpuprofile files.
Note: My goal is to see the call tree and bottom-up. I do not care about flame chart.
Thanks.

I ended up downloading an old Chromium version. http://commondatastorage.googleapis.com/chromium-browser-continuous/index.html?prefix=Win_x64/381909/

There is a vscode extension for viewing .cpuprofile:
Flame Chart Visualizer for JavaScript Profiles
https://marketplace.visualstudio.com/items?itemName=ms-vscode.vscode-js-profile-flame

Yes, it seems the format has changed. From NodeJS v9.11.1 I'm getting a tree-like JSON structure:
{
"typeId": "CPU",
"uid": "1",
"title": "Profile 1",
"head": {
"functionName": "(root)",
"url": "",
"lineNumber": 0,
"callUID": 1319082045,
"bailoutReason": "no reason",
"id": 17,
"hitCount": 0,
"children": [
{
"functionName": "(anonymous function)",
"url": "...",
"lineNumber": 726,
"callUID": 3193325993,
"bailoutReason": "no reason",
"id": 16,
"hitCount": 0,
"children": [
{
...
From Chromium 66.0.3359.117 I'm getting a flat structure:
{
"nodes": [
{
"id": 1,
"callFrame": {
"functionName": "(root)",
"scriptId": "0",
"url": "",
"lineNumber": -1,
"columnNumber": -1
},
"hitCount": 0,
"children": [
2,
3
]
},
{
...
What worked for me is the chrome2calltree tool, which takes the old format used by NodeJS and turns it into a .prof file that tools like KCacheGrind and QCacheGrind can open.

Related

Data is getting embedded via a local json file

I'm trying to plot some data, that data is in a pandas dataframe cdfs:
alt.Chart(cdfs).mark_line().encode(
x = alt.X('latency:Q', scale=alt.Scale(type='log'), axis=alt.Axis(format="", title='Response_time (ms)')),
y = alt.Y('percentile:Q', axis=alt.Axis(format="", title='Cumulative Fraction')),
color='write_size:N',
)
The issue is that when viewing the source of the resultant plot there is just a url to a json file. That json file can't be found and hence the plots are appearing to be blank (no data).
{
"config": {"view": {"continuousWidth": 400, "continuousHeight": 300}},
"data": {
"url": "altair-data-78b044f23db74f7d4408fba9f31b9ea9.json",
"format": {"type": "json"}
},
"mark": "line",
"encoding": {
"color": {"type": "nominal", "field": "write_size"},
"x": {
"type": "quantitative",
"axis": {"format": "", "title": "Response_time (ms)"},
"field": "latency",
"scale": {"type": "log"}
},
"y": {
"type": "quantitative",
"axis": {"format": "", "title": "Cumulative Fraction"},
"field": "percentile"
}
},
"$schema": "https://vega.github.io/schema/vega-lite/v4.8.1.json"
}
This code was previously working (displaying the data on the chart) however I restarted the jupyterlab server its running on between now and then.
Hence I'm wondering why the data is getting embedded via a url rather than directly all of a sudden?
At some point in your session, you must have run
alt.data_transformers.enable('json')
If you want to restore the default data transformer which embeds data directly into the chart, run
alt.data_transformers.enable('default')

Azure Form Recognizer Not Behaving As Expected

I am having an issue with FormRecognizer not behaving how I have seen it should. Here is the dilemma
I have an Invoice that, when run through https://{endpoint}/formrecognizer/v2.0/layout/analyze
it recognized the table in the Invoice and generates the proper JSON with the "tables" node. Here is an example of part of it
{
"rows": 8,
"columns": 8,
"cells": [
{
"rowIndex": 0,
"columnIndex": 4,
"columnSpan": 3,
"text": "% 123 F STREET Deer Park TX 71536",
"boundingBox": [
3.11,
2.0733
],
"elements": [
"#/readResults/0/lines/20/words/0",
"#/readResults/0/lines/20/words/1"
]
}
When I train a model with NO labels file https://{endpoint}/formrecognizer/v2.0/custom/models It does not generate an empty "tables" node, but it generates (tokens). Here is an example of the one above without "table"
{
"key": {
"text": "__Tokens__12",
"boundingBox": null,
"elements": null
},
"value": {
"text": "123 F STREET",
"boundingBox": [
5.3778,
2.0625,
6.8056,
2.0625,
6.8056,
2.2014,
5.3778,
2.2014
],
"elements": null
},
"confidence": 1.0
}
I am not sure exactly where this is not behaving how intended, but any insight would be appreciated!
If you train a model WITH labeling files, then call FR Analyze(), the FR service will call the Layout service, which returns tables in "pageResults" section.

Loading json data into Cassandra using dsbulk

I feel like the documentation on loading json files into cassandra is really lacking in dsbulk docs.
Here is part of the json file that im trying to load:
[
{
"tags": [
"r"
],
"owner": {
"reputation": 23,
"user_id": 12235281,
"user_type": "registered",
"profile_image": "https://www.gravatar.com/avatar/60e28f52215bff12adb9758fc2cf86dd?s=128&d=identicon&r=PG&f=1",
"display_name": "Me28",
"link": "https://stackoverflow.com/users/12235281/me28"
},
"is_answered": false,
"view_count": 3,
"answer_count": 0,
"score": 0,
"last_activity_date": 1589053659,
"creation_date": 1589053659,
"question_id": 61702762,
"link": "https://stackoverflow.com/questions/61702762/merge-dataframes-in-r-with-different-size-and-condition",
"title": "Merge dataframes in R with different size and condition"
},
{
"tags": [
"python",
"location",
"pyautogui"
],
"owner": {
"reputation": 1,
"user_id": 13507535,
"user_type": "registered",
"profile_image": "https://lh3.googleusercontent.com/a-/AOh14GgtdM9KrbH3X5Z33RCtz6xm_TJUSQS_S31deNYUcA=k-s128",
"display_name": "lowhatex",
"link": "https://stackoverflow.com/users/13507535/lowhatex"
},
"is_answered": false,
"view_count": 2,
"answer_count": 0,
"score": 0,
"last_activity_date": 1589053657,
"creation_date": 1589053657,
"question_id": 61702761,
"link": "https://stackoverflow.com/questions/61702761/want-to-get-a-grip-of-this-pyautogui-command",
"title": "Want to get a grip of this pyautogui command"
}
]
The way I have been trying to load this is following:
dsbulk load -url ./data_so1.json -k stackoverflow_t -t staging_t -h '182.14.0.1' -header false -u username -p password
This is the closest i get and it pushes the values into Cassandra row by row like this:
data
-------------------------------------------------------------------------------------------------------------------------------
"title": "'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine giving exception on client"
"profile_image": "https://www.gravatar.com/avatar/05085ede54486bdaebefcf8363e081e2?s=128&d=identicon&r=PG&f=1",
"view_count": 422,
"question_id": 61702768,
"user_id": 12235281,
This just takes the rows as they are (including the commas). I've tried the -m key for mapping but didnt really get anywhere with it.
What would be the right way to get these values to their own respective columns?

Creating a Chrome app that just goes to a website/shortcut

There is a site we use that is also a webapp that will work offline as well as online once you open the first time. We currently manually create a desktop shortcut in the chrome browser by bringing up the site, then clicking on the browser menu, go to More Tools, then Create Shortcut. We also check the box for "Open as Window". This then not only puts a shortcut that always opens in Chrome no matter what but also opens it a little cleaner it would appear. When this is done an extension is created on the computer in the Google extensions folder. I'd like to convert this to a Chrome app that can be deployed via group policy but even after going through the developer instructions I can't seem to get it to work.
I've taken the manifest.json that was created when I did it manually and added the missing parameters required of a chrome app, or at least from what I can tell. I've even published the app in the chrome webstore. But it just doesn't seem to work.
The original Manifest.json contains:
{"app": {
"icon_color": "#C02331",
"launch": {
"web_url": "https://www.example.com/RunForm/Login"
},
"linked_icons": [ {
"size": 16,
"url": "https://www.example.com/Content/images/favicon.ico"
}, {
"size": 32,
"url": "https://www.example.com/Content/images/favicon.ico"
}, {
"size": 48,
"url": "https://www.example.com/Content/images/runform/apple-touch-icon-76x76.png"
}, {
"size": 64,
"url": "https://www.example.com/Content/images/runform/apple-touch-icon-76x76.png"
}, {
"size": 76,
"url": "https://www.example.com/Content/images/runform/apple-touch-icon-76x76.png"
}, {
"size": 96,
"url": "https://www.example.com/Content/images/runform/apple-touch-icon-120x120.png"
}, {
"size": 120,
"url": "https://www.example.com/Content/images/runform/apple-touch-icon-120x120.png"
}, {
"size": 128,
"url": "https://www.example.com/Content/images/runform/apple-touch-icon-152x152.png"
}, {
"size": 152,
"url": "https://www.example.com/Content/images/runform/apple-touch-icon-152x152.png"
}, {
"size": 256,
"url": "https://www.example.com/Content/images/runform/apple-touch-icon-152x152.png"
} ]
},
"description": "",
"icons": {
"120": "icons/120.png",
"128": "icons/128.png",
"152": "icons/152.png",
"16": "icons/16.png",
"256": "icons/256.png",
"32": "icons/32.png",
"48": "icons/48.png",
"64": "icons/64.png",
"76": "icons/76.png",
"96": "icons/96.png"
},
"key": "sKDvXmTdpPytbue4P6yYy+6MRc+SMw5PutBMuCo/yLs=",
"name": "Run Form Login",
"version": "2019.5.28.54363"}
And then I added:
"manifest_version": 2,
"name": "Run Form Login",
"description": "RunForm Login Page",
"update_url": "https://clients2.google.com/service/update2/crx",
"permissions": [
"unlimitedStorage",
"notifications"
]
I was expecting that this would then be installed via GPO as an extension like the one I did manually. And then having a desktop shortcut to "C:\Program Files (x86)\Google\Chrome\Application\chrome_proxy.exe" --profile-directory=Default --app-id=[xx_TheAppIdOfTheExtension_xx] would just open then site in the window like it does when we make the link manually. However it just opens Chrome. And it doesn't look like the extension is ending up in the extension folder either even though the information for forced installs is correct in chrome://policy

Flickr API Not Returning Actual Photos

Hi i'm on a project and want to use Flickr for my image galery, i'm using the photosets.* method but whenever i make a request i don't get images, i only get info.
Json Result:
{
"photoset": {
"id": "77846574839405047",
"primary": "88575847594",
"owner": "998850450#N03",
"ownername": "mr.barde",
"photo": [
{
"id": "16852316982",
"secret": "857fur848c",
"server": "8568",
"farm": 9,
"title": "wallpaper-lenovo-blue-pc-brand",
"isprimary": "1",
"ispublic": 1,
"isfriend": 0,
"isfamily": 0
},
{
"id": "16665875068",
"secret": "857fur848c",
"server": "7619",
"farm": 8,
"title": "white_horses-1280x720",
"isprimary": "0",
"ispublic": 1,
"isfriend": 0,
"isfamily": 0
}
],
"page": 1,
"per_page": "2",
"perpage": "2",
"pages": 3,
"total": "6",
"title": "My First Album"
},
"stat": "ok"
}
Please would like to have actual image URLs returned, how can i do this.
Thanks to the comment by #CBroe
I found this in the Flickr API doc.
You can construct the source URL to a photo once you know its ID, server ID, farm ID and secret, as returned by many API methods.
https://farm{farm-id}.staticflickr.com/{server-id}/{id}_{secret}.jpg
or
https://farm{farm-id}.staticflickr.com/{server-id}/{id}_{secret}_[mstzb].jpg
or
https://farm{farm-id}.staticflickr.com/{server-id}/{id}_{o-secret}_o.(jpg|gif|png)
The final result would then look something like this.
https://farm1.staticflickr.com/2/1418878_1e92283336_m.jpg
Reference: https://www.flickr.com/services/api/misc.urls.html

Resources