Profile மற்றும் analyze
Profile: எதை Rust-க்கு மாத்துறது லாபம்னு கண்டுபிடிங்க
வேகம் தான் நோக்கம்னா, எதையும் தேர்ந்தெடுக்குறதுக்கு முன்னாடி அளந்து பாருங்க:
rust-anything profile <repo> -- node bench.mjs # அல்லது: python3 bench.py, ruby bench.rb,
# java -cp out Main, go test -run X -bench . ./pkg
profile ஒரு real workload-ஐ அந்த மொழியோட profiler (node, cProfile, go test pprof, JFR, ஒரு Ruby tracer) கீழ run பண்ணி, inclusive time படி hot functions-ஐயும், அவற்றை call பண்ற callers-ஐயும், எந்த loops-ஐ batch பண்ணணும்ங்கிறதையும் list பண்ணும். Go-ல go test வழியா மட்டும் தான் profile பண்ண முடியும்; C-க்கு support இல்ல.
- ஒவ்வொரு item-க்கும் ஒரு தடவை call ஆகுற சின்ன function-ஐத் தனியா port பண்றது லாபம் இல்ல: Rust-க்கு ஒரு தடவை boundary தாண்டி call பண்ற செலவே அதோட வேலையை விட அதிகம், மேலும் JITs (V8, JVM, Go) அதை nanoseconds-ல முடிச்சுடும். அதை அதோட callers கூட சேர்த்து port பண்ணுங்க, இல்லன்னா batch பண்ணுங்க. எதைப் பண்ணணும்னு advice line சரியான command கூடவே சொல்லிடும்.
- ஏற்கனவே compile ஆன code (numba
@njit, Cython,@jax.jit) machine code-ஆவே ஓடும்: Rust port அங்க பெரிய வேகம் தராது.profileஅதை "Already compiled" கீழ list பண்ணும்.
Analyze: port-ஐ plan பண்ணுங்க
rust-anything analyze <repo> -o plan.md # மனுஷங்க படிக்க
rust-anything analyze <repo> --json # agents-க்கு: schema rust-anything/analyze@1
rust-anything analyze <repo> --whole-app # கூடுதலா entry points, shape, dependencies, decisions
analyze units, port order, file:line உடன் risks, ஒவ்வொரு unit-க்குமான bridge, ஒவ்வொரு dependency-உம் ஒரு crate கூட எந்த அளவுக்குப் பொருந்துது, மற்றும் start_here (முதல்ல port பண்ணச் சிறந்த இடங்கள்) ஆகியவற்றை list பண்ணும். --whole-app இதோட app-ஓட shape (CLI, server அல்லது library) மற்றும் entry points, import ஆன இல்ல declare ஆன எல்லா dependencies-உம் அவற்றோட crate-உம், pieces (ஒண்ணையொண்ணு import பண்ற units சேர்ந்து நகரும்), மற்றும் recommended பதிலோட நம்பர் போட்ட decisions-ஐயும் சேர்க்கும். பார்க்க: முழு app-ஐயும் port பண்ணுங்க.
-
Packages (
package.json) மற்றும் source files;node_modules, build output, fixtures, playgrounds, tool configs ஆகியவற்றைத் தவிர்க்கும். Vue/Svelte/Astro<script>blocks-ல இருக்கிற imports-உம் parse செய்யப்படும். -
Units: source files உள்ள ஒரு folder, அல்லது ஒரு package-ஓட source root-ல உள்ள ஒரு file.
-
Waves: ஒரு unit import பண்றவை முந்தைய waves-ல வரும்; import cycles-ஐ ஒண்ணா சேர்த்து port பண்ணுவோம்.
-
Bridge: unit-க்கு அல்லது அது import பண்ற எதுக்காவது Node தேவைப்பட்டா napi-rs; portable code-க்கு wasm-bindgen; UI மற்றும் editor code-ஐ JS-லயே வச்சுக்கலாம்.
-
Readiness (எவ்வளவு safe) 100-ல இருந்து தொடங்கி கீழே உள்ளவற்றைக் கழிச்சு, 0–100-க்குள்ள clamp பண்ணும்:
Term Weight ஒவ்வொரு risk-உம் அதோட severity weight (high 6, medium 3, low 1) × ln(1 + count), அதனால ஒரு high risk 4.2 குறையும்Size lines / 40Fan-in இதை import பண்ற ஒவ்வொரு unit-க்கும் 1.5, அதிகபட்சம் 15Dependencies Rust பொருத்தம் இல்லாத ஒவ்வொரு crate-க்கும் 12, table-ல இல்லாத ஒவ்வொரு crate-க்கும் 4 Tests ஒரு test file நேரடியா import பண்ணுனா +10; அதோட package-ல மட்டும் tests இருந்தா +4 (வேறொரு package-ல இருக்கிற test இதை பேர் சொல்லி import பண்ணுனாலும் கணக்குல வரும்) -
Density: 100 lines-க்கு இருக்கிற loops மற்றும் string-offset operations எண்ணிக்கை; பயன்படுத்துறதுக்கு முன்னாடி ஒரு decimal-க்கு round செய்யப்படும்.
-
Priority பாதி readiness, பாதி value, முழு எண்ணா round பண்ணி 0–100-க்குள்ள clamp செய்யப்படும்; இங்க value அதிகபட்சம் 100 வரை சேரும். Report-க்காக round பண்றதுக்கு முன்னாடி இருக்கிற readiness fraction-ஐ இது பயன்படுத்தும், அதனால ரெண்டு units-உம் 100-ன்னு print ஆனாலும் score வேற வேறயா வரலாம்:
Term Weight Compute density × 4, அதிகபட்சம் 50Tests ஒரு test file நேரடியா import பண்ணுனா 30, அதோட package-ல மட்டும் tests இருந்தா 15 Size 80-க்கு கீழே lines / 4, 80 முதல் 600-க்கு முன்னாடி வரை 20, 600 மற்றும் அதுக்கு மேல 10 -
Start here குறைஞ்சது 20 lines-உம் குறைஞ்சது ஒரு bridgeable export-உம் கொண்ட
readyunits-ஐ எடுத்து, priority, அப்புறம் readiness (ரெண்டுமே பெரியது முதல்ல), wave (முந்தையது முதல்ல), density (அதிகம் முதல்ல) மற்றும் id அடிப்படையில வரிசைப்படுத்தி, முதல் பத்தை வச்சுக்கும். மூணுக்கும் குறைவா தகுதி பெற்றா,readyமற்றும்cautionunits-ல இருந்து திரும்பத் தேர்ந்தெடுக்கும். அதுவும் காலியா இருந்தா (20 lines உள்ள எந்த unit-லயும் bridgeable export இல்லன்னா) size வரம்பை நீக்கிடும். அதனால ஒரு unit 20 lines-ஐத் தாண்டுனாலே இந்த list மாறலாம்.
கீழே உள்ள ஒவ்வொரு risk-உம் plans-ல அதை உருவாக்குன lines கூட title xN-ன்னு வரும்; அது வழக்கமா எவ்வளவு சிக்கலானதுங்கிறதையும் ஒரு உதாரணத்தையும் இந்த table சொல்லும். analyze score பண்ண பயன்படுத்துற severities இவைதான்.
| Risk | Severity | எங்க அடி வாங்கும் |
|---|---|---|
| String offsets மற்றும் slicing | high | TS/JS slice, indexOf, matchAll; Python, Ruby, PHP (substr, strpos), Java, Kotlin, C#, Go-ல string indexing மற்றும் slicing; C strlen, strcpy, sprintf: offsets Rust-ஓட UTF-8 bytes-ல இல்லாம UTF-16 units, characters அல்லது bytes-ல எண்ணப்படும் |
regex crate-ல இல்லாத regex features |
high | TS/JS, Python, Ruby, PHP, Java, Kotlin, C#, Go regexp, PowerShell -match/-replace: lookaround, backreferences, y flag |
| Runtime-ல உருவாகுற regexes | high | TS/JS, Python, Ruby, PHP, Java, C#, PowerShell: new RegExp(pattern), re.compile(s), literal-ஆ இல்லாத pattern |
| Dynamic code (eval, new Function, computed import) | high | TS/JS eval, new Function, computed import(); Python exec, compile, __import__; Ruby eval, instance_exec; PHP eval, create_function; PowerShell Invoke-Expression, Add-Type |
| Dynamic typing | medium | TS/JS any, 'key' in value; Python getattr, isinstance; Ruby method; PHP ==; Java instanceof மற்றும் casts; Kotlin is/as; C# dynamic, is/as; Go interface{} மற்றும் type switches; PowerShell $script:/$global: |
| Insertion-ordered maps மற்றும் object keys | medium | TS/JS Map, Set, Object.keys; PHP arrays; Ruby hashes; PowerShell [ordered] dictionaries |
| Async மற்றும் promises | medium | TS/JS Promise மற்றும் async/await; Python async/await; C# async/await |
| Generators | medium | TS/JS function*; Python, Ruby மற்றும் PHP yield; C# yield மற்றும் LINQ queries |
| Class inheritance | medium | TS/JS, Python, Ruby, PHP, Java, Kotlin, C#, PowerShell classes: extends, base classes, mixins மற்றும் traits |
| Reflection மற்றும் prototypes | medium | TS/JS Proxy, Reflect, Symbol; Python globals/vars; Ruby send, is_a?; PHP variable variables; Java java.lang.reflect, getClass(); Kotlin ::class; C# System.Reflection; Go reflect; C function-like macros |
| Callback-shaped APIs | medium | TS/JS, Ruby, PHP, Java, Kotlin, C#, Go, PowerShell script blocks: function-typed parameters bridge-ஐ ரொம்ப chatty-ஆக்கும் |
| Exceptions | low | பத்து மொழிகளிலும்: throw, raise, try, Go panic/recover/defer, C setjmp/longjmp/abort/exit/signal, PowerShell trap/Write-Error |
| Number semantics | low | TS/JS number, bitwise operators, Math.round, toFixed, parseInt/parseFloat (மற்றும் Number.parseInt/Number.parseFloat); Python bitwise operators; PHP /; C# decimal |
| JSON round-trips | low | TS/JS JSON, Ruby, PHP, Go encoding/json, PowerShell ConvertTo-Json: key வரிசை, undefined, NaN |
| Integer width மற்றும் overflow | medium | Python, Ruby மற்றும் PHP ** மற்றும் <<; Java, Kotlin, C# shifts, * மற்றும் hash codes; Go மற்றும் C shifts மற்றும் conversions: wrap ஆகுமா இல்ல panic ஆகுமா |
| Division மற்றும் modulo | medium | Python, Ruby, PHP, Java, Kotlin, C#, Go, C: negative எண்கள் மேல / மற்றும் %, Python // |
| Hash iteration order | high | Python set; Java மற்றும் Kotlin HashMap/HashSet; C# Dictionary/HashSet; Go map range; PowerShell @{} hashtables |
| Pointers மற்றும் manual memory | high | C pointers, malloc, memcpy; Go unsafe மற்றும் pointer types; C# unsafe |
| Concurrency | medium | Go goroutines மற்றும் sync, Java மற்றும் Kotlin threads மற்றும் synchronized, C# lock மற்றும் System.Threading, Python, Ruby, PHP மற்றும் C threads, PowerShell Start-ThreadJob |
| Null references | medium | Java, C#, PHP null; Kotlin nullable types; Go மற்றும் Ruby nil; C NULL; PowerShell $null |
| Code-ல runtime மாற்றங்கள் | high | Ruby define_method மற்றும் அது சார்ந்தவை, Python Class.method = ..., PHP class_alias/runkit_*/uopz_* |
| ஏற்கனவே compile ஆனவை (numba, Cython, JAX) | medium | Python: இனிமேலும் சாதாரண Python-ஆ இல்லாத decorated code |
| numpy array parameters | high | Python: np.ndarray arguments மற்றும் returns |
| Platform-specific C (asm, volatile, bitfields, packing) | high | C: asm, volatile, :3 bitfields, #pragma pack |
| Clock மற்றும் random numbers | low | TS/JS Date.now/Math.random, Python time.time/random/os.urandom, PowerShell Get-Date/Get-Random/New-Guid: napi bridge உடனான TS/JS-ஐயும் Python-ஐயும் record --pin-clock cover பண்ணும்; மத்த இடங்கள்ல கையால ஒப்பிடணும் |
| Implicit output மற்றும் pipeline | medium | PowerShell: Write-Output, echo மற்றும் capture பண்ணாம விட்ட values pipeline-க்குப் போகும் |
| Case-insensitive comparison | medium | PowerShell -eq, -like, -match, -contains மற்றும் switch ஆகியவை case-ஐப் பார்க்காது |
| Implicit type conversion | medium | PowerShell: [int]"abc" மாதிரியான casts, மற்றும் integers மேல / double கொடுக்கும் |
| Intl மற்றும் locale-aware strings | high | TS/JS Intl.*, localeCompare, toLocaleLowerCase, toLocaleString (மற்றும் அதோட Date, Time வடிவங்கள்), normalize("NFC"): engine ICU data; ICU4X பெரும்பாலானவற்றை cover பண்ணும், CJK word breaks மாறுபடும் |
| Date parsing | high | TS/JS Date.parse, new Date(string): V8-ஓட பழைய formats மற்றும் local time; date generator வச்சு test பண்ணுங்க |
| URL மற்றும் encoding APIs | medium | TS/JS new URL, URLSearchParams, TextEncoder/TextDecoder, atob/btoa: url crate அதே standard-ஐப் பின்பற்றுது |
analyze வெளியிடுற அதே 31 titles-உம், அது score பண்ற severities-உம் இவைதான்; src/risks.rs தான் அந்த list.
Dependencies-க்கான crates
Code import பண்ற ஒவ்வொரு library-க்கும் analyze ஒரு Rust crate பெயரைச் சொல்லி, அதோட பொருத்தத்தை good, partial அல்லது none-ன்னு காட்டும். அதோட table-ல இல்லாத library-ஐ unknown-ன்னு report பண்ணும்; table எப்பவும் ஒரு crate-ஐக் குத்துமதிப்பா guess பண்ணாது. ஒண்ணைச் சேர்க்கணும்னா Contributing பாருங்க.